Why does the array a not get initialized by global variable size?
#include
int size = 5;
int main()
{
int a[si
#include
/* int size=5; */
#define size 5 /* use this instead*/
/*OR*/
int a[size]={1,2,3,4,5}; /* this*/
int main()
{
int a[size]={1,2,3,4,5};
printf("%d",a[0]);
return 0;
}
int size means that size is a variable and C does not allow variablesize arrays.
I am using VS2008 where using
const int size=5;
allows
int a[size]={1,2,3,4,5};