C Programming: Memory, Pointers and the Stack · Pointers
A pointer can point to another pointer. Follow the chain with ** to reach the value at the end.
#include <stdio.h>
void reset(int **pp) {
**pp = 0; /* changes the int at the end of the chain */
}
int main(void) {
int value = 9;
int *p = &value;
int **pp = &p; /* a pointer to a pointer */
int seen = **pp;
reset(pp);
printf("%d %d\n", seen, value);
return 0;
}value is created on the stack with the value 9.p is created on the stack with the value → value.reset(), with pp = → p. It gets its own variables on the stack.reset() has finished, so its variables are gone.9 0.0.