Pointer To Pointer (Double Pointer)

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:

2Ue KslLEToTWas0DNluH 3NLpoN1PD5ejFfRRKSXR0gCiXrFN3o3Uum yNRp5Oe2gO1nlK6LIqN8IbpUwGq

Difference between single pointer and double-pointer:

Single PointerDouble 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;
Difference Between Double and Single Pointer

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.

Default image
Soham Malakar
Hello my name is Soham Malakar am currently pursuing BCA Coding is one of my favorite hobbies. I love to code and an enthusiast to learn different types of programming languages. I love to get intoxicated in the world of technology and video games. A quick learner possessing better results.
Articles: 40

Newsletter Updates

Enter your email address below to subscribe to our newsletter

Leave a Reply