I am new to C programming. I am trying to set the size of the array using a variable but I am getting an error: Storage size of \'array\' isn\'t constant !!
To create an array of a non-constant size (i.e. known at compile time), you need to dynamically allocate space for it using malloc()
(and correspondingly deallocate it using free()
when it is no longer required).
As others have noted, the ability to declare dynamic arrays is available in C99 compliant compilers.