Pointers, multidimensional arrays, and addresses

Suppose we have: int A [5] [2] [3]; Now, if I do this: A [1] [0] [0] = 4; does it mean:

1.) Are A [1] and A [1] [0] pointers?

2.) If A [1] is a pointer, will it save the address of the pointer A [1] [0]?

3.) If A [1] [0] is a pointer, then it will save the address A [1] [0] [0], which is NOT a pointer, but simply a variable that stores the value 4

If the above points are correct, then why use the following code, which gives us the same integer address:

int main(void)
{
        int A [5] [2] [3];
    A[1][0][0]=4;

    printf("%d\n\n", A[1]);
    printf("%d\n\n", A[1][0]);
    printf("%d\n\n",&A[1][0][0]);

        system("pause");
}

, A [1] , A [1] [0] , , A [1] [0]. , A [1] [0] - , A [1] [0] [0] , , V [

, !

+5
6

, , C. , :

http://webster.cs.ucr.edu/AoA/Windows/HTML/Arraysa2.html http://archive.gamedev.net/archive/reference/articles/article1697.html http://www.ibiblio.org/pub/languages/fortran/append-c.html

.


, , , :

int A[5][2][3] 5 * 2 * 3: ints. ,

&A[0][0][0] == A
&A[0][0][1] == A+1
&A[0][1][0] == A+(1*3)
&A[3][1][2] == A+(3*(2*3))+(1*3)+2

A[1] , . int [2][3]. , , A[5][2][3] , ints.

A[0][0][0] is the first integer in that region. 
A[0][0][1] is the second integer. 
A[0][0][2] is the third integer. 
A[0][1][0] is the fourth integer in this flat region. 
A[0][1][1] is the fifth integer. 
And so on until A[1][0][0] is the eleventh integer. 

A[1][0][0] A[0][0][0]; .. &A[1][0][0] - &A[0][0][0] == 10. C , A[1] , , , " ," " .

A[1] , . &A[0][0][0] &A[5][2][3]-1 .

, (2) (3), , - .

, C-.

, C , - , C PDP-11 56 . , , , , - , .

C , langauge .

, , Qaru . , , , , .

+4

c . , , . C :

char a[5][7][9]
a[d][h][w]  <<==>>  ((char*)a)[((9*7*d)+(9*h)+w] 

C , ( ).

a[1]  (char[7][9])    --decay-->   ((*char)[5][9]) pointer to char array
&a[1] ((*char)[5][9])  no decay

, "" , .

+1

, (.. malloc/calloc).

, , . A[X][Y][Z], *(A + X*YSIZE*ZSIZE + Y*SIZE + Z), *(*(*(A+X) + Y) + Z). ( ), , .

C.

+1

A - 5 * 2 * 3 ints, . (I.e., 30 ints).

`int A [5] [2] [3]; ' - - 30 int.

, A , , 3 , 3, , int . , , ; , .

+1

, , , C , . (, )

0

, . , 1 6, 1 6. , ( ) , (1-3) A, (4-6) B.

[1 2 3] [4 5 6]

, , ? ! , ? , !

, , ? , ! , , , GROUP B ? , .


; A [1] - (), A [1] [0] , ( ) (A [1]), ! : & A [1] [0] [0], , , ? .

, . , .

0

All Articles