With the following codes:
int a=5,*b,**c; b=&a; c=&b;
We have:
+---+ a | 5 | <-- value +---+ |100| <-- address +---+ +---+ *b |100| <-- value +---+ |200| <-- address +---+ +---+ **c |200| <-- value +---+ |300| <-- address +---+
When you store a's address in b, b's value is a's address. But b has it's own address (200). c can store b's address as it's value. But c has it's own address too (300).
printf("%x", &c); will give you: 300
Deferencing *c will get you down "1 level" and give you 100 (get value of address 200)
Deferencing **c will get you down 1 more level and give you 5 (get value of address 100)
If you try to use *c instead of **c to hold *b, how are you able to deference all the way down to reach value 5?
Testing the codes on a compiler:
printf("Address of a: %x\n", &a); printf("Address of b: %x\n", &b); printf("Address of c: %x\n", &c); printf("Value of a: %d\n", a); printf("Value of b: %x\n", b); printf("Value of c: %x\n", c);
Output:
Address of a: 28ff44 Address of b: 28ff40 Address of c: 28ff3c Value of a: 5 Value of b: 28ff44 Value of c: 28ff40