Pointer and two-dimensional array access

 

Two-dimensional array as a parameter

 

The internal arrangement of the two-dimensional array p[3][3]:

 

p[0][0]=*p[0]==**p

 

 

p[1][0]=*p[1]=**(p+1)

*(*(p+1)+1)

 

p[2][0]=*p[2]=**(p+2)

 

 

Here **p is *(*p)

*(p+1)=p+1, but *(p+1) is the column pointer, p+1 is still the row pointer

p[1]=*(p+1), that is, both are column pointers

 

To summarize, for a two-dimensional array

If it is with and only a * or a [] sign (one of the two), then the access is the column pointer (the column pointer points to the specific element (that is, the address of the element) to access the value of the element, Need to add a * or []

If there are two * or two [], or even one * and one [] (both appearing once at the same time), then specific elements can be accessed

Guess you like

Origin blog.csdn.net/xuchaoxin1375/article/details/114842694