The array must be sized at compile time, so it cannot be declared as
intaa[variable]; and must be declared as
Therefore, it cannot be done like
int aa[i]; and should be used using dynamic allocation like
int *aa=malloc(sizeof(int)*i);. However, the i value must not be less than or equal to zero.
For your information, C99 also has a variable length array, but it is not used very well. https://en.wikipedia.org/wiki/Variable-length_array
© 2022 pinfo. All rights reserved.