Home C-tutorials C Multiple Indirection



C Multiple Indirection
Posted on: February 5, 2009 at 12:00 AM
C permits the pointer to point to another pointer. This creates many layers of pointer and therefore called as multiple indirection.

C Multiple Indirection

     

This section illustrates you the concept of Multiple Indirection.

C permits the pointer to point to another pointer. This creates many layers of pointer and therefore called as multiple indirection. A pointer to a pointer has declaration is similar to that of a normal pointer but have more asterisk sign before them. This indicates the depth of the pointer. You can see in the given example, we have declared an integer variable i initialized to 100. The statement int ** pt creates a pointer which points to pointer to a variable with int value. We have passed the value of i to pointer pt2 and to pass the value of pt2 to pt1, we have used the statement pt1 = &pt2; which shows the Multiple Indirection.

Here is the code:

MULTINDI.C

#include <stdio.h>
#include <conio.h>
void main() {
  int i =100;
  int **pt1;
  int *pt2;
  clrscr();
  pt2 = &i;
  pt1 = &pt2;
  printf("The value of **pt1 = %d \n "+
  "The value of *pt2 = %d"
, **pt1, *pt2);
  getch();
}

Output will be displayed as:

Download the source code

Related Tags for C Multiple Indirection:
ciomultiplepointeriprmiintthiscreateforpoicalltopointrefeitmultinotmitulpelayersmanlayerinnormcalasmntcaindirectionesdirectiondirallsrecttipdirectatanyisirlleaandssthmanyiplpleplmindono


More Tutorials from this section

Ask Questions?    Discuss: C Multiple Indirection  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.