# concepts on 3d array

This is a discussion on concepts on 3d array within the C Programming forums, part of the General Programming Boards category; Could anyone please clear the following ideas regarding a 3d array to me? 1. for an array, int arr[i][j][k], does ...

1. ## concepts on 3d array

Could anyone please clear the following ideas regarding a 3d array to me?

1. for an array, int arr[i][j][k], does arr++ mean anything?
2. is cube (or a rectangular parallelepiped to be precise) a correct reperesentation of a 3d array? if so, how can i increment/decrement a particular cell data, say data at 1,2,2?

Thanks,
Angshu

2. >1. for an array, int arr[i][j][k], does arr++ mean anything?
Nope, it's an error.

>2. is cube (or a rectangular parallelepiped to be precise) a correct reperesentation of a 3d array?
You can think of it that way if you want, but in memory a 3 dimensional array is just a one dimensional array with a little extra stuff to make indexing work like the cube representation.

>how can i increment/decrement a particular cell data, say data at 1,2,2?
Code:
`++arr[1][2][2];`

3. >1. for an array, int arr[i][j][k], does arr++ mean anything?
Nope, it's an error.
However, it does mean something on a pointer, such as int ***p. Just like with 1D and 2D arrays.

4. >However, it does mean something on a pointer, such as int ***p.
However, the question wasn't about a pointer, it was about an array.

5. Originally Posted by dwks
However, it does mean something on a pointer, such as int ***p. Just like with 1D and 2D arrays.
Also, since we're at it, you're a bit misleading here. This statement implies that incrementing a pointer has the same, or similar, effect as incrementing 1D and 2D arrays. Which of course is false, because you can't do: arrayname++, no matter how many dimensions it has.

Quzah.

6. Another way it's misleading is dwks' statement implies that if you have an array:
Code:
```int a[50][50][50];
int b[50];```
And then you have:
Code:
```int ***p = a;
int *q = b;```
Then p++ will be useful in traversing the array, and it isn't. Though q++ is.