1,498 views

2 Answers

Best answer
6 6 votes
int a = 10;
int *b;          //Single Pointer
int **c;         // Double Pointer
int ***d;        //Triple Pointer

/* Single Pointer */

// Here b is a sigle pointer hence its capable of storing the address
// of a variable.

b = &a; //Valid operation

printf("%d\n",*b); //To acess the value at address which is stored in b

// & is called as "address of" operator
// * is called as "dereferencing operator" or "value at address" operator

/* Double Pointer */

// Here c is double pointer hence,

c = &b; //Valid operation

c = &a; // Not valid, Program may not generate compile time error but definitely
        // generate a warning "suspicious pointer conversion" and wil generate a
        // runtime eerror.
        
printf("%d\n",**c); // this is the way to access the data from double pointer

/* Triple Pointer */

// Here d is a triple pointer. 

d = &c; // Valid operation

d = &b; //Will generate the run time error as we have seen above
d = &a; // Runtime error

printf("%d",***d); // To access the value trough d.

After this, If you have any specific doubt then ask in comment I will answer all. Enjoy. 

• selected by
4 4 votes

Well, your question popped two questions in my mind. First, if you are asking how triple pointers can be implemented and used(the syntax) and second, if you are interested in knowing the practical utility of triple pointers. The former has been vividly answered by  @rude , for the latter version ( i suppose this can be a good question too :P ) here I go.

For example, let's take a char pointer so that char pointer can point to a string, better say a sentence. Now imagine many such pointers, each pointing to a sentence.
Next, think of a pointer that points to the collection(array) of all the above pointers. It will point to a collection of sentences and hence it is analogous to a page.

And here comes the third pointer which can point to the collection of all page pointers and represent a chapter.

Something like this :

Triple Pointer

Add another pointer (fourth pointer) and you will have a book !

• edited by
Position:
Show:

Related questions

4 4 votes
1 1 answer
857
857 views
ritwik_07 asked Jun 10, 2023
857 views
#include<stdio.h #include<string.h #define MAX(x, y) ((x) (y) ? (x) : (y)) int main() { int i = 10, j = 5, k = 0; k = MAX(i++, ++j); printf("%d %d %d", i, j, k); return ...
1 1 vote
1 1 answer
1.3k
1.3k views
Rajib Datta Roy asked Jun 2, 2022
1,272 views
int main(){ int x=5,*p; p=&x; *p=x++ + *p; printf ("%d %d",x,*p);}We have this programnowhere *p= 5++ + (*p) - *p= 5 + 5 =10 so x location is 10and then the pos...
0 0 votes
1 1 answer
888
888 views
Sk Jamil Ahemad asked Feb 1, 2022
888 views
Please explain with some example that How Right to Left associativity takes place in case of Ternary operators?
1 1 vote
1 answers 1 answer
1.7k
1.7k views
kaveeshnyk asked May 7, 2019
1,721 views
#include<stdio.h int main(){ int (*a)[5]; int arr[5][5]={ {10,65,300,400,500}, {100,20,3000,40,5000} }; a = arr; ++a ; char *ptr = (char*)*a...