| Previous | Home | Next |
# Pointer to Pointer
A pointer to a pointer is a form of a chain of pointers. A pointer contains the address of a variable. When we define a pointer to a pointer, the first pointer contains the address of the second pointer, which points to the location that contains the actual value as shown below.
# For example, following is the declaration to declare a pointer to a pointer of type int:
int **var;
Example
#include <stdio.h>
int main ()
{
int a;
int *ptr;
int **ptptr;
a = 1000;
/* take the address of a */
ptr = &a;
/* take the address of ptr using address of operator & */
ptptr = &ptr;
/* take the value using pptr */
printf("Value of a = %d\n", a );
printf("Value available at *ptr = %d\n", *ptr );
printf("Value available at **ptptr = %d\n", **ptptr);
return 0;
}
Value of a = 1000
Value available at *ptr = 1000
Value available at **ptptr = 1000
| Previous | Home | Next |