What is pointer to pointer in C Language?

In case of a pointer to pointer concept, one pointer refers to the address of another pointer. The pointer to pointer is a chain of pointers. Generally, the pointer contains the address of a variable. The pointer to pointer contains the address of a first pointer. Let’s understand this concept through an example:


  1. #include <stdio.h>
  2.  int main()
  3. {
  4.     int a=10;
  5.     int *ptr,**pptr; // *ptr is a pointer and **pptr is a double pointer.
  6.     ptr=&a;
  7.     pptr=&ptr;
  8.     printf(“value of a is:%d”,a);
  9.     printf(“\n”);
  10.     printf(“value of *ptr is : %d”,*ptr);
  11.     printf(“\n”);
  12.     printf(“value of **pptr is : %d”,**pptr);
  13.     return 0;
  14. }

In the above example, pptr is a double pointer pointing to the address of the ptr variable and ptr points to the address of ‘a’ variable.