The pointer is a variable which stores the memory address of another variable. So, when we define a pointer to pointer. The first pointer is used to store the address of the variable. And the second pointer is used to store the address of the first pointer. That is why they are also known as double pointers.
Syntax :
Data_type **variable_Name ;
Example :
int **q ;
q => This is double pointer variable and not normal variable
A triple-pointer is a pointer that points to a memory location where a double-pointer is being stored. The triple-pointer itself is just one pointer. Ex. int *** is a pointer, that points to the value of a double pointer, which in turn points to the value of a single pointer, which points to the value of an int.
Syntax :
Data_type ***variable_Name ;
Example :
int ***r ;
r => This is double pointer variable and not normal variable
Here is an example of a double pointer being used in a program:
The program uses the triple dereference operator *** to print the value stored at the memory address stored in r , which is the value of q
This program demonstrates how to declare and initialize a single pointer, a double pointer and a triple pointer, how to set them to the memory address of a variable, how to print the value stored at a memory address and how to dereference a pointer variables.
#include<stdio.h> int main() { int a=10,*p; int **q; // Pointer to Pointer or Double Pointer int ***r; //Triple Pointer p=&a; //Address of a printf("\n Value of A : %d",a); printf("\n Address of A : %d",&a); printf("\n Value of P : %d",p); printf("\n Address of P : %d",&p); printf("\n P Dereferencing : %d",*p); printf("\n------------------------------------"); q=&p; printf("\n Value of P : %d",p); printf("\n Address of P : %d",&p); printf("\n Value of q : %d",q); printf("\n Address of q : %d",&q); printf("\n **Q Dereferencing : %d",**q); printf("\n------------------------------------"); r=&q; printf("\n Value of q : %d",q); printf("\n Address of q : %d",&q); printf("\n Value of r : %d",r); printf("\n Address of r : %d",&r); printf("\n ***r Dereferencing : %d",***r); printf("\n------------------------------------"); return 0; }To download raw file Click Here
Value of A : 10 Address of A : 6356732 Value of P : 6356732 Address of P : 6356728 P Dereferencing : 10 ------------------------------------ Value of P : 6356732 Address of P : 6356728 Value of q : 6356728 Address of q : 6356724 **Q Dereferencing : 10 ------------------------------------ Value of q : 6356728 Address of q : 6356724 Value of r : 6356724 Address of r : 6356720 ***r Dereferencing : 10 ------------------------------------
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions