First look at the following program:
Void main () {int a = 100; int * ap = & a; printf ("% p \ n", & a); // output: 002AF744printf ("% p \ n", ap); // output: 002AF744printf ("% d \ n", * ap); // output: 100 printf ("% p \ n", & ap); // output: 002AF738printf ("% p \ n", & * ap); // output: 002AF744scanf ("% d ");}
1. printf ("% d \ n", & a); // output: 002AF744
This sentence outputs the address of variable a, which is beyond doubt.
2. printf ("% d \ n", ap); // output: 002AF744
This sentence is the value of the output pointer, which is the same as an output, that is, the value of the pointer is the address of the variable pointed to by the pointer.
3. printf ("% d \ n", * ap); // output: 100
A * sign is added before the pointer variable. The ap pointer without the star number points to the address of variable, the addition of * actually becomes the content of the variable a pointed to by the ap,
Therefore, we can understand that * is an operation to get the content of the address pointed to by the pointer variable.
4. printf ("% d \ n", & ap); // output: 002AF738
This statement (same as 1) is the address for obtaining the ap pointer variable.
5. printf ("% d \ n", & * ap); // output: 002AF744
According to the analysis at, * ap points to the content of variable a, and & * ap is the address for obtaining the content of variable, is the address of variable a, so the output content is the same as (1)