Could someone explain how 3d arrays work? The question I have is :
For 1 d arrays we refer to an element as A[i]
for 2d , A[i][j].
But when we use 3 d arrays how do we find out what A[i][j][k] refers to, that is, what the value stored in it is?
Could someone explain how 3d arrays work? The question I have is :
For 1 d arrays we refer to an element as A[i]
for 2d , A[i][j].
But when we use 3 d arrays how do we find out what A[i][j][k] refers to, that is, what the value stored in it is?
1) You have an array of something. 0 through size - 1.Code:int array[ XSIZE ]; int twodee[ YSIZE ][ XSIZE ]; int threedee[ ZSIZE ][ YSIZE ][ XSIZE ];
2) You have an array of those arrays. 0 through thissize - 1.
3) You have an array of those arrays. 0 through thisothersize - 1.
And so on. It's easy to keep track of it if you just read it from right to left.
An array, XSIZE big...
An array of those, YSIZE big...
An array of those, ZSIZE big...
Quzah.
Hope is the first step on the road to disappointment.