C does provide a direct syntax for this:
type name[size_1][size_2]....[size_n];
To reference an item, the syntax is slightly different to most languages:
name[i][j]...[z]
C defines a 2D array to be a 1D array, each of whose elements is an array. Elements are thus stored by rows: the rightmost subscript varies most rapidly as we move directly through store. As this statement holds for multi-dimensional arrays, we have effectively dealt with that too.
C is much more powerful than most languages in that it has a uniform integration of pointers and arrays. Note in particular the following.
1. Given a one-dimensional array a, a is a constant pointer to the start of it. It follows that &a is meaningless.
2. If a is two-dimensional, a[0] is a constant pointer to the first row; a[1] is a constant pointer to the second row etc.
3. If a is higher-dimensional, then all terms such as a[2], a[3][2], a[0][1][2]... are similar constant pointers: only when we have all of the indexes in place do we refer to the actual variable storage.
All such constants are address values compiled into the code, which is why they are not variables!
4. All storage for a particular array is contiguous, regardless of the dimensionality.
5. Array pointers are no different from any others, in the sense that there is no bounds checking and the star (*) operator can be used.
maspjw@