Possible Duplicate:
How do I use arrays in C++?
In the following code snippet:
int a[2][3][2]={{{1,2},{9,8},{3,7}},{{2,2},{1,4},{5,4}}};
what will be the answers for a[i],a[i][j] ,where i<=1 and j<=2
I have no problem in understanding the a[i][j][k] working.Can you please explain how does the above indexing works?
The thing you have to remember here is that the there are 2 different objects you are working with.
and
The first is an int, the other 3 are pointers
The associated memory’s look like this:
And so on…
Now in the example you make you do arithmic operations with pointers eg.
a[1] - a[0] = 3. If you look at the memory associated wit that you can see there are 3 memory locations between the 2 pointers, thus the result is 3.