Double & Triple pointer in C


We already know that a pointer points to a location in memory and thus used to store the address of variables. 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.

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.

Source Code

#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

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C


Learn All in Tamil © Designed & Developed By Tutor Joes