Home : C Language : Variables : Arrays
Array declarations are of the form:
[attributes]
typename[size];
Each element (of type type) within the array is accessed using
name[index], where index is in the range 0 to size - 1 inclusive.
Multi-dimensional arrays may be declared:
[attributes]
typename[sizeA][sizeB][sizeC];
Each element within the array is accessed using name[indexA][indexB][indexC].
Initial values may be specified:
[attributes]
typename[size] = {constant,constant,constant};
[attributes]charname[size] = "string";
Initialised arrays may have their size determined by the number of values listed:
[attributes]
typename[] = {constant,constant,constant};
[attributes]charname[] = "string";
name refers to the base address of an entire array (i.e. this is
exactly equivalent to &name[0]). Note that this means only the base address of any array can be passed
to a function, the value of the array itself cannot be passed.
Arrays and structures may be nested to several levels.