How about this approach? Thinking of a chessboard:
Code:
startofboard = 1024; // start address
noofcols = 8; // length of each dimension
noofrows = 8;
square = startofboard; // name of the element in the array
endofboard = startofboard + (noofcols * noofrows); // end address,
// for reference by the next array
// to access a square for column col_no and row row_no:
current_sq = square[(col_no -1) * noofcols + (row_no -1));
// or
sq_index = (col_no -1) * noofcols + (row_no -1);
current_sq = square[sq_index];
--------------
or for a 3D chessboard
startofboard = 1024;
noofcols = 8;
noofrows = 8;
nooflayers = 8;
cube = startofboard;
endofboard = startofboard + (noofcols * noofrows * nooflayers);
// to access a particular square:
current_cube = cube[((layer_no -1) * nooflayers + (col_no -1)) * noofcols + (row_no -1));
// or
cube_index = ((layer_no -1) * nooflayers + (col_no -1)) * noofcols + (row_no -1);
current_cube = cube[cube_index];