Double Pointer Operator in C Programming Language

Notes:

Double Dereferencing (or Double pointer or Pointer to Pointer) operator (**) in C:
- is used to create a variable; which holds the address of another pointer variable
- a variable; which holds address of another pointer variable is called a double pointer
- is also called as a double indirection operator

Note: Double pointer operator
- is used to create a pointer to a pointer variable
- is also used to get or set the value at another pointer is pointing

Syntax:
data_type **variableName;
Ex:
int **ptr2 =NULL; // ptr2 is a pointer which holds address of another pointer of type int

Example Code:
#include <stdio.h>
int main()
{
int a = 10;
int *ptr1 = &a;
int **ptr2 = &ptr1;

printf("Value of a= %d\n",a); // Value of a= 10
printf("Address of a= %d\n",&a); // Address of a= 22 93 532
printf("\n");

printf("Value of ptr1= %d\n",ptr1); // Value of ptr1= 22 93 532
printf("Address of ptr1= %d\n",&ptr1); // Address of ptr1= 22 93 528
printf("\n");

printf("Value of ptr2= %d\n",ptr2); // Value of ptr2= 22 93 528
printf("Address of ptr2= %d\n",&ptr2); // Address of ptr2= 22 93 524
printf("\n");

printf("Value of a= %d\n",a); // Value of a= 10
printf("Value of a using ptr1= %d\n",*ptr1); // Value of a using ptr1= 10
printf("Value of a using ptr2= %d\n",**ptr2); // Value of a using ptr2= 10
printf("\n");

a = 20;
printf("Value of a= %d\n",a); // Value of a= 20
printf("Value of a using ptr1= %d\n",*ptr1); // Value of a using ptr1= 20
printf("Value of a using ptr2= %d\n",**ptr2); // Value of a using ptr2= 20
printf("\n");

*ptr1 = 30;
printf("Value of a= %d\n",a); // Value of a= 30
printf("Value of a using ptr1= %d\n",*ptr1); // Value of a using ptr1= 30
printf("Value of a using ptr2= %d\n",**ptr2); // Value of a using ptr2= 30
printf("\n");

**ptr2 = 40;
printf("Value of a= %d\n",a); // Value of a= 40
printf("Value of a using ptr1= %d\n",*ptr1); // Value of a using ptr1= 40
printf("Value of a using ptr2= %d\n",**ptr2); // Value of a using ptr2= 40
printf("\n");

return 0;
}