Let's take the following example where we swap the values of a and b.
void swap(int* a, int* b) {
// remember, a and be are both memory addresses now!
printf("The address of a is: %p\n", a);
printf("The address of address-of a is: %p\n", &a);
int tmp = *a;
*a=*b;
*b=tmp;
}
The printout gives me:
The address of a is: 0x7ffd36e62d08
The address of address-of a is: 0x7ffd36e62cd8
What exactly does the second printf
statement tell us? For example:
int a = 4;
&a; // address-of a
int* b; = &a;
b; // address-of a
*b; // value-of a
&b; // address-of ...?
Is that just the location of the memory address on the stack?