How to define pointer to pointer in C language?

Declaring double pointer is similar to declaring pointer in C programming language. The difference is that only we need to add an additional ‘*’ before the name of pointer.


The syntax is given below for declaring double pointers −

int **ptr;


Following is the C program for pointer to pointer −

 Live Demo

// C program to demonstrate pointer to pointer
int main(){
   int element = 24;
   // pointer for element
   int *ptr2;
   // double pointer for ptr2
   int **ptr1;
   // storing address of value in ptr2
   ptr2 = &element;
   // Storing address of ptr2 in ptr1
   ptr1 = &ptr2;
   // Displaying value of element using
   // both single and double pointers
   printf("element value = %d
", element );    printf("element value using single pointer = %d
", *ptr2 );    printf("element value using double pointer = %d
", **ptr1);    return 0; }


When the above program is executed, it produces the following result −

element value =24
element value using single pointer = 24
element value using double pointer = 24