C language two-level pointer and multi-level pointer

What is a secondary pointer?

Assumptions:

int a = 10;

int * p = &a;

As above, p is a pointer variable, which stores the address of a and points to the element a

So, does the pointer variable p have an address? What does the pointer of the pointer variable p point to?

int * * pp = &p;

The answer is yes, the pointer variable also has an address, and the pointer variable p also has a pointer variable pp pointing to its address, and because the address pointed to by the pointer pp variable is the pointer variable p, and the pointer variable p points to the address a, so the pointer The variable pp is called a secondary pointer.

int * * pp 

pp points to the pointer variable p, pp also represents the pointer variable, int* represents the address type pointed to by the pointer pp is int*, and * represents a pointer.

At the same time, because the second-level pointer pp points to the address of the pointer p, and the address of the element a is stored in the pointer p, so according to the progressive relationship, the second-level pointer is finally printed, and the value in the element a is obtained.

printf("%d",**pp);

 And finally, we can obtain the third-level pointer through derivation. The principle of the third-level pointer is the same as that of the second-level pointer. The second-level pointer variable also has an address, and the address of the second-level pointer variable is stored in the third-level pointer variable. The addresses of the first-level pointer variables are stored in the first-level pointer variables, and the addresses of other non-pointer variables are stored in the addresses of the first-level pointer variables.

And so on in the end……………………

Guess you like

Origin blog.csdn.net/2301_76445610/article/details/132248767