The C language allows arrays larger than two dimensions. The limit on the number of dimensions (if any) is determined by the specific compiler. The general description form of multi-dimensional arrays is:
Type-specifier name [a][b][c]...[z];
Due to the large amount of memory they occupy, arrays of two or more dimensions are rarely used. As mentioned before, when the array is defined,
all array elements will be allocated to the address space. For example, a four-dimensional character array of size (1 0, 6, 9, 4) requires 1 0
×6×9×4, which is 2 1 6 0 bytes.
If the above array is a two-byte integer, 4 3 2 0 bytes are required. If the array is a double word (assuming that each double
word is 8 bytes) requires 3 4 5 6 0 bytes, and the storage capacity increases exponentially as the number of dimensions increases.
One thing to note about multi-dimensional arrays: the computer spends a lot of time calculating array subscripts, which means that accessing elements in multi-dimensional arrays is more difficult than accessing elements in one-dimensional arrays. Elements take more time. For these and other reasons, a large number of multi-dimensional arrays generally use the C language to dynamically allocate functions and pointers, and dynamically allocate storage space to a part of the array at a time.
When a multi-dimensional array is passed to a function, all dimensions except the first dimension must be specified. For example, define the array m as:
int m[4][3][6][5];
Then the function receiving m should be written as:
< p>func1 (d)int d[][3][6][5];
Of course, you can also add a description of the first dimension if you like.