Two C language pointer (a pointer to a pointer)

  1. As we all know, is a pointer to the memory address, it can point to a common data types, such as int, double, char, etc.

    Note that, the pointer may point to a type of correction data, e.g. int *, double *, char *, etc.

    If a pointer to a pointer to another, we call two pointer, or a pointer to a pointer.

E.g:

int a =100;

int *p1 = &a;

int **p2 = &p1;

  I just saw this int ** p2, I really do not understand why there are two ** it?

  I think so: a identifier is stored in memory 100, the pointer p1 points to a corresponding address, p1 is stored in a memory address, and if we need a pointer to point p1 address us directly int * p2 = & p1 is not good enough, why should int ** p2 = & p1. After careful consideration, I have an idea:

  It is also a pointer variable variable will take up storage space, can also be used &to obtain its address. C language does not limit the number of stages of pointers, one for each additional pointer, when defining a pointer variable must increase asterisk *. p1 is a pointer to a common type of data, there is a defined time *; P2 is the second pointer to a pointer p1, when there are two definitions *.

  We see p1 is of type int * pointer variable that points to the address type int

  The reason why there will be two int ** p2 * p2 is because we are pointing to a pointer of type int *, it is a two pointer to a pointer p1. We can break down look int ** p2, we can be seen as int * (* p2), where * p2 that this is a pointer, int * represent * p2 points to a pointer of type int *

I do not know that you understand it?

  In the vernacular talk about it, you see, we point to an int int * address the need for a statement, that if we want to point to int * type of address, should we have a statement int ** a!

 

Guess you like

Origin www.cnblogs.com/lililixuefei/p/11855981.html