(1) The format of pointer variable definition:
Type identifier * variable name; such as: int *point;
Note: When defining int point; When , the bold part is not a value operator, but modifies that point is a pointer variable. How to determine what type of variable point points to? You need to proceed to the next step: look at the non-bold part, int means that point points to an int type variable. Or save the address of an int type variable.
(2) Initialization of pointer variables, let’s look at an example first:
Description:
Indicates that the type of the variable is a pointer variable, and the pointer variable name It is p1, not p1;
If multiple pointer variables are defined on the same line, they should be: int *p1, *p2; not int p1, p2 or int p1, p2;
There are two ways to initialize pointer variables:
Initialize when defining, such as int *p_2 = &b;
Define first and then initialize, such as int *p1; p1 = &a;
*p1 is the value of the variable pointed to by p1;
A pointer variable can only point to variables of the same type.
(3) For the two operators "*" and "&" of pointer variables:
& takes the address operator //&a represents the address of a (referring to The starting address of the memory space where a is located)