A pointer is a variable which hold the address of another variable. A pointer to pointer is one which hold the address of the pointer that has the address of another variable holding the value.
Syntax Of Double Pointer:
datatype variable;
datatype *pointer;
datatype **pointer1
pointer = &variable;
pointer1 = &pointer;
Let us take an example to make it more clear:
#include<stdio.h> int main() { int a=10; int *p=&a; int **p1=&p; printf("\nThe value of the variable using single pointer: %d",*p); printf("\nThe value of the variable using double pointer: %d",**p1); return 0; }
The above program shows the example of double pointer where the pointer variable p is addressed by another pointer variable p1. Hence illustrating the technique of pointer to pointer.
Output:
Difference between single pointer and double-pointer:
Single Pointer | Double Pointer |
A pointer which hold the address of a variable having a specific value. | A pointer which hold the address of another pointer variable. |
It is represented by:data type *name; | It is represented by data type **name; |
Hence we reach to end of a short and simple discussion on pointer to a pointer. Hope we have cleared all your doubts.
Please comment and share this article if you find it helpful and to improve this article please WhatsApp me.