The size of the array must be a compile time constant. However, C99 supports variable length arrays. So instead of your code working in your environment, if the size of the array is known at runtime, then -
int *s = malloc(sizes);
Regarding the error message:
int a[5]; // ^ 5 is a constant expression int b = 10; int aa[b]; // ^ b is a variable. So, it value can differ at some other point. const int size = 5; int aaa[size]; // size is constant.
Mahesh
source share