Array of pointers and two-dimensional array pointer

http://c.biancheng.net/view/2022.html

 

#include <bits/stdc++.h>
using namespace std;
int a[3][4]={1,2,3,4,5,6,7,8,9,10,11,12};
int main()
{
    int (*p)[4] =a;
    for(int i =0;i<3;i++){
        for(intJ = 0 ; J < . 4 ; J ++ ) { 
            the printf ( " % 2D " , * (* (P + i) + J)); 
        } 
        / * 
        * (P + i): the first address of the i-th line data 
        * ( p + i) + j: address of i-th row and j th column of elements 
        * / 
        the printf ( " \ n- " ); 
    } 
    return  0 ; 
}

 

int * p1 [5] // pointer array int (* p1 [5]) as the
int (* p2) [5] // pointer to a two-dimensional array
pointer array, each element is a pointer, the 32-bit environment p1 accounting for 5 * 4 = 20 bytes
dimensional array pointer is a pointer to a two-dimensional array. p2 occupies four bytes

Guess you like

Origin www.cnblogs.com/tingtin/p/11504657.html