1. Multidimensional Arrays

Okay let's say that we have an 3x3 array of int*.

Now since the array (a 3x3 array of int*) needs to be dereferenced 3 times (***) to get the value of an int that one of the elements hold the address to, this must mean that just having the array name point to the first element of row one can't be possible because then only 2 levels of indirection would be needed to gain access to an int value. This must mean (for this individual example, a 3x3 int* array), that 3 additional pointers will be needed. These additional pointers (to pointers, int**) will hold the address of the first pointers in each row of the array. The actual array name will hold the address of the first of the previous 3 pointers (this pointer, an int***) and each of the 3 previous pointers being next to each other in memory (so that pointer arithmetic can take place).

Now this is just how I see it as working. Is this even correct? (If not I would like to know how this actually works..)

Now if this is correct, I already see that the same thing would be needed for a simple 2D array of int (rather than int*), except step each pointer level down 1 notch..

2. yes for a three level array this would be correct, but a 3x3 array usually means three rows by three colums, not three directions of space.

3. Originally Posted by loopshot
yes for a three level array this would be correct, but a 3x3 array usually means three rows by three colums, not three directions of space.
Thats what I meant, a 2D array of int*, 3 rows of 3 columns.

Would that make it not correct?

4. yea because in this array you only need to specify the row, then the colum to access a element, think about it.

array[0][0], first element
array[2][2], last element
array[1][1], middle element

as you can see we can get every where with 2 specifications

5. Originally Posted by loopshot
yea because in this array you only need to specify the row, then the colum to access a element, think about it.

array[0][0], first element
array[2][2], last element
array[1][1], middle element

as you can see we can get every where with 2 specifications
I think you've misunderstood; To get the int value held in the address in say, array[0][0] (since this is a 2D array of pointers to int), you need to dereference it 1 more time - *array[0][0];

And the first post was my idea of how this is worked out..

6. yea but it is still the same thing, you only need 2 pointers to access any data in the array, then you can dereference or what every, it dosent matter.

7. Originally Posted by loopshot
yea but it is still the same thing, you only need 2 pointers to access any data in the array, then you can dereference or what every, it dosent matter.
I'm not talking about how many times the thing has to be dereferenced to get whatever is stored in an element, I'm talking about how many hidden pointers are needed to make it work correctly. It is not possible for the array name to be a pointer to each array in the 2D array and a pointer to each element in those array so there has to be hidden pointers involved! That's what I'm asking about. I understand that you only have to dereference the thing twice (which is something I've always understood), but that is not what I'm asking about.

8. Your original post was a bit hard to follow, but I think your understanding is correct.

9. i think we just had a misunderstanding about what you where talking about, i still dont.