Pointer to Pointer in C Language with Free Notes

Pointer to Pointer

Since each and every variable declared in a program is assigned an address, so a Pointer variable also has an address.

Pointer to Pointer means that a variable can be declared which can store address of a Pointer variable.

e.g.    
int i, *j, **k;
i = 5;
j = &i;
k = &j;
  • In this example i as an integer variable, j is Pointer variable which is pointing to i and k is Pointer to Pointer i.e. Pointer to j.
  • Its Memory map can be shown as
C Language Notes
  • To Access a Variable i through double Pointer k, we can use **k, **k means value at (value at address k)
value at address k = 2002 
So value at (value at address k i.e. 2002) = 5

Example: Demonstration to print the value of i using Pointer to Pointer.

void main ()
{
  int i = 5, *j, **k;
  j = &i;
  k = &j;
  print f("\n Address of i = %u%u", &i, j);
  print f("\n Address of j = %u%u", &j, k);
  print f("\n Value of i = %d%d%d", i, *j, **k);
 }

Output

Address of i = 2002 2002
Address of j = 4004 4004 
Value of i  = 555

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top