Programming in C: Unit III (b): Pointers

Pointers to Pointers

with Example C Program

In C language you are also allowed to use pointers that point to pointers. The pointers in turn, point to data (or even to other pointers). To declare pointers to pointers, just add an asterisk (*) for each level of reference.

POINTERS TO POINTERS

In C language you are also allowed to use pointers that point to pointers. The pointers in turn, point to data (or even to other pointers). To declare pointers to pointers, just add an asterisk (*) for each level of reference. For example, if we have:

int x = 10

int *px; //pointer to an integer

int **ppx; // pointer to a pointer to an integer

px = &x;

ppx = &px;

Assume that the memory location of these variables is as shown in Figure 7.9.

Now if we write,

printf("\n %d", **ppx);

then it will print 10, the value of x.


Programming in C: Unit III (b): Pointers : Tag: : with Example C Program - Pointers to Pointers