Im having a little trouble understanding pointers.If I declare a multi-dimensional array char ma[10][30]. What is the address of the element "ma[2][20]"? if the address must be assigned to the pointer variable, that’s not "p = &ma[2][20]".)
Im having a little trouble understanding pointers.If I declare a multi-dimensional array char ma[10][30]
Share
A multidimensional array is really just a contiguous chunk of memory. In this case the array is a chunk of chars (bytes) 10*30 = 300 bytes in size. The compiler is handling the accessing of this array via the two ‘dimensions’.
The address of ma[2][20] is the address of ‘ma’ + 2*30 + 20 or ‘ma+80’ bytes. ‘ma’ is the address of the start of the chunk of memory representing the array.