#include <stdio.h>
const int i=1;
int a[i];
int main()
{
printf("Hello World");
return 0;
}
Size of an array must be a constant expression. I have declared i to be const, why still the error?
main.c:12:5: error: variably modified 'a' at file scope
int a[i];
^
Why does moving the part inside the function main work:
#include <stdio.h>
int main()
{
const int i=1;
int a[i];
printf("Hello World");
return 0;
}
Thanks.