On the discussion of dynamic memory here: \"Intro to C Pointers and Dynamic Memory\"
The author states:
A memory block like this can effective
Because
int array[variable];
isn't valid in standard C -- you can only define the length of an array with a constant. (such as your
char name[] = "Nick";
example, which isn't variable-length).
As such, it's necessary to use a memory allocator like calloc() if you want to create an array of a length based on a program variable.
Just don't forget to free() it.