Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Is the pointer an address? Isn't the pointer variable an address?
Is the pointer an address? Isn't the pointer variable an address?
A pointer is an address, and an address is a pointer; A pointer variable is a variable that holds the address of a basic type variable.

If the pointer variable P holds the address of the variable A, it is said that P points to A, and *p is the variable A. ..

If p is a pointer variable, *p means a variable with the content of p as the address, that is, the variable pointed by p.

Pointer can be understood as a special language mechanism, which stores the addresses of other variables, and the contents of the addresses can be obtained through the dereference operator *. This also creates a directional relationship.

The type of each variable is derived, and foo_p is a pointer to int, so the type of foo_p is int*, that is, add int before' *'; Foo_pp is also a pointer to foo_p, so the type of foo_pp is int**, which means adding int* before' *'.

Extended data

Initialization of pointer variable:

You can use an assignment statement to make a pointer variable get the address of another variable so that it points to it. For example:

int i,* j; J = &

In this way, the address of the variable I is put into the pointer variable J. Through the address of I, J can find the data in I, so J "points" to the variable I ... where & is the address operator, which is the & concept as & scanf; * is a "pointer operator" whose function is to obtain the contents of the variable pointed by the address of the variable stored in it.

Because J is defined as a pointer variable, only the address of the variable can be stored in J, so the variable I must be preceded by&; . It should be noted that only addresses can be stored in pointer variables. Do not assign integers or any other non-address data to pointer variables.

In addition, there are two points to note:

1, J is not I, I is not J. Modifying the value of J will not affect the value of I, and modifying the value of I will not affect the value of J. J is the address of variable I, and I is the data in variable I, one is "the address of storage unit" and the other is "the content of storage unit".

2. The meaning of "*j" when defining pointer variables is different from that of "*j" used in the program. The "*j" when defining a pointer variable is just a declaration. At this time, the "*" only means that the variable is a pointer variable, and there is no other meaning.

Moreover, the pointer variable does not point to any variable at this time. As for the specific variables to be specified in the program, pointer variables are initialized. When j is specified to point to the variable I, *j is completely equivalent to I and can be substituted for each other.