Pointers to pointers are a form of multilevel indirection, or a pointer chain. Typically, 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, and the second pointer points to the position that contains the actual value.
A pointer variable pointing to a pointer must be declared as follows, placing two asterisks before the variable name. For example, the following declares a pointer to the INT type pointer:
int * *var;
When a target value is indirectly directed to another pointer by one pointer, access to the value requires the use of two asterisk operators, as shown in the following example:
1#include <stdio.h>2 3 intMain ()4 {5 int var;6 int*ptr;7 int**pptr;8 9 var= the;Ten One /*get the address of Var*/ APTR = &var; - - /*Use the operator & get the address of PTR*/ thePptr = &ptr; - - /*get a value using Pptr*/ -printf"Value of var =%d\n",var ); +printf"Value available at *ptr =%d\n", *ptr); -printf"Value available at **pptr =%d\n", **pptr); + A return 0; at}
When the above code is compiled and executed, it produces the following results:
var the about
C Pointer to pointer