0 0 votes Use of triple pointer ? Programming in C + – mithilesh kumar 1 1.5k views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
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. rude answered May 24, 2016 • selected Jun 10, 2016 by rude rude comment Share Follow See 1 comment 1 1 comment reply asu commented Jun 11, 2016 reply Follow flag what is the datatype of c and d 0 0 replyShare Please log in or register to add a comment.
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 : Add another pointer (fourth pointer) and you will have a book ! Shubhi Tiwari answered May 26, 2016 • edited May 26, 2016 by Shubhi Tiwari Shubhi Tiwari comment Share Follow 0 reply Please log in or register to add a comment.