Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Pointer constant, null pointer, pointer-to-pointer,&; p,* p & amp; (*p),*(& amp; P) Please explain in detail how to distinguish and understand these.
Pointer constant, null pointer, pointer-to-pointer,&; p,* p & amp; (*p),*(& amp; P) Please explain in detail how to distinguish and understand these.
Pointer constant means that the position pointed by the pointer cannot be changed, that is, the pointer itself is a constant. But pointer constants can modify data in memory through indirect references.

The format of the statement defining the pointer constant is as follows:

Pointer type *const Pointer constant =& = & Variable name

For example, an integer variable Inta =1is defined; At the same time, a pointer p is defined to point to this variable a: int * p =&; a;

But when I run out of this variable and pointer, I release the memory space pointed by the pointer: free (p); At this point, the data 1 in the memory space pointed by P is cleared, but there is still an address in the pointer P (the address that originally pointed to the memory space of variable A). At this time, it is usually necessary to set the pointer p to a null pointer: P = NULL.

Pointer variables pointing to pointers are defined in the following form:

Type name * * Pointer variable name;

"* * pointer variable name" is equivalent to "* (* pointer variable name)", which means storing the value of pointer variable.

Is the address of another pointer variable whose value can only be accessed through two indirect accesses.

& can be a reference or address extraction character, such as int p;; Then & p, that is, take the address. When using references, you can also define aliases for variables. *p is to define a pointer. (*p) *p is a value stored in the p address, plus & this is the address where this value is taken, * (&; P) This is to take the value of address p first (p can be an address) and then take the value of this address.

Actually, you don't need it. I deleted it and I had to rewrite it. Thank you anyway. The key is that you understand! :))