Variable Lenght Array

A variable-length array (VLA), also called variable-sized or runtime-sized, is an array data structure whose length is determined at run time (instead of at compile time). In C90 arrays are of constant and predetermined size. This means that you've to specify the size directly as a number of with #define. The array size is locked into the program at compile time.

const int size = 5;
int arr[size]; /* Wrong */
warning: ISO C90 forbids variable length array ‘arr’ [-Wvla]

since size is a variable and not an integer constant!.

C99 can handle variable-length array (VLA), also called variable-sized or runtime-sized, is an array data structure whose length is determined at run time (instead of at compile time). You cannot initialize a VLA because the compiler cannot assure that the initializer size matches the array size. C99 allows VLA but not the initialization of these objects

int size = 2;
int arr[size] = {0,1}; /* Wrong */

would yield:

error: variable-sized object may not be initialized
«Epoxides Index Sulfides»