POINTERS TO POINTERS
The concept of pointers can be further extended. Pointer we know is a variable which contains address of another variable. Now this variable itself could be another pointer. These we now have a pointer which contains another pointer’s address. The following example should make this point clear.
main ()
{
int i = 3 ;
int * j ;
int * * k ;
j = & i ;
k = & j ;
printf (“\n address of i = % \d”, & i );
printf (“\n address of i = % \d”, j );
printf (“\n address of i = % \d”, * k );
printf (“\n address of j = % \d”, & j );
printf (“\n address of j = % \d”, k );
printf (“\n address of k = % \d”, & k );
printf (“\n address of k = % \d”, &k );
}
In this program i is an integer type value, j is a pointer to this variable and k is another pointer type variable pointing to j.
i j k
3 6485 3276
6485 3276 7234
All the addresses are assumed addresses K is pointing to the variable j. These K is a pointer to pointer. In principle, there could be a pointer to a pointer’s pointer, of a pointer to a pointer to a pointer’s pointer. There is no limit on how far can we go on extending this definition.
Showing posts with label Pointers to Pointers. Show all posts
Showing posts with label Pointers to Pointers. Show all posts
Sunday, November 16, 2008
Subscribe to:
Comments (Atom)