First look at the following program:
Copy Code code as follows:
void Main ()
{
int a = 100;
int *ap = &a;
printf ("%p\n", &a);//output: 002af744
printf ("%p\n", AP);//output: 002af744
printf ("%d\n", *ap);//output: 100
printf ("%p\n", &ap);//output: 002af738
printf ("%p\n", &*ap);//output: 002af744
scanf ("%d");
}
1. printf ("%d\n", &a);//output: 002af744
The output of this sentence is the address of variable a, no doubt.
2. printf ("%d\n", AP);//output: 002af744
This is the value of the output pointer, which is the same as one output, that is, the value of the pointer is the address of the variable to which the pointer points
3. printf ("%d\n", *ap);//output: 100
With a * number in front of the pointer variable, the AP pointer without an asterisk is the address of the variable a, and the * really becomes the content of the variable A that the pointer ap points to.
So, we can understand that the * number is an operation that gets the contents of the address that the pointer variable points to.
4. printf ("%d\n", &ap);//output: 002af738
This sentence (same 1) is the address of the AP that gets the pointer variable
5. printf ("%d\n", &*ap);//output: 002af744
According to the 3rd analysis, *ap points to the content of variable A, and &*ap is the address of the content of variable A, that is the address of variable A, so the output is the same (1)