Pointers to Pointers in C

In c programming language, we have pointers to store the address of variables of any datatype. A pointer variable can store the address of normal variable. C programming language also provides pointer variable to store the address of another pointer variable. This type of pointer variable is called as pointer to pointer variable. Sometimes we also call it as double pointer. We use the following syntax for creating pointer to pointer…

datatype **pointerName ;


int **ptr ;

Here, ptr is an integer pointer variable that stores the address of another integer pointer variable but does not stores the normal integer variable address.

Points to be Remembered

  1. To store the address of normal variable we use single pointer variable
  2. To store the address of single pointer variable we use double pointer variable
  3. To store the address of double pointer variable we use triple pointer variable
  4. Similarly the same for remaining pointer variables also…

Example Program


void main()
   int a ;
   int *ptr1 ;
   int **ptr2 ;
   int ***ptr3 ;

   clrscr() ;

   ptr1 = &x ;
   ptr2 = &ptr1 ;
   ptr3 = &ptr2 ;
   printf(“Address of ‘x’ = %u\n”, ptr1) ; 
   printf(“Address of ‘ptr1’ = %u\n”, ptr2) ;
   printf(“Address of ‘ptr2’ = %u\n”, ptr3) ;
   getch() ;