To make an array declaration, write
[length] after the
name being declared. This construct is valid in the declaration of a
variable, a function parameter, a function value type (the value can’t
be an array, but it can be a pointer to one), a structure field, or a
The surrounding declaration specifies the element type of the array;
that can be any type of data, but not
void or a function type.
a as an array of 5
struct foo bstruct[length];
bstruct as an array of
length objects of type
struct foo. A variable array size like this is allowed when
the array is not file-scope.
Other declaration constructs can nest within the array declaration construct. For instance:
struct foo *b[length];
b as an array of
length pointers to
struct foo. This shows that the length need not be a constant
(see Arrays of Variable Length).
c as a pointer to an array of 5
char *(*f (int));
f as a function taking an
int argument and
returning a pointer to an array of 5 strings (pointers to
aa as an array of 5 elements, each of which is an
array of 10
doubles. This shows how to declare a
multidimensional array in C (see Multidimensional Arrays).
All these declarations specify the array’s length, which is needed in these cases in order to allocate storage for the array.