C examples for Pointer:Introduction
To declare a pointer pointing to another pointer.
When the address stored in the first pointer changes, the second pointer can follow that change.
int** r = &p; /* pointer to pointer */
Referencing the second pointer now gives the address of the first pointer.
Dereferencing the second pointer gives the address of the variable, and dereferencing it again gives the value of the variable.
#include <stdio.h> int main(void) { int i = 10; /*from ww w .j a v a2 s . c om*/ int* p; /* pointer to an integer */ p = &i; /* address of i assigned to p */ int** r = &p; /* pointer to pointer */ printf("Address of p: %p \n", r); /* ex. 0017FF28 */ printf("Address of i: %p \n", *r); /* ex. 0017FF1C */ printf("Value of i: %d", **r); /* 20 */ }