Pointer variable can themselves
point to data elements, which is also a pointer.
This is known as multiple in directions. There is no
limit on this, we can point to any number of pointer variables.
However, each level of indirection adds further
level of complexity to the program.
Example:
int *ptr;
int a=100;
ptr=&a;
Where ptr is a pointer variable which has as the address of a which
points to an inter value of 100.
The value stored in a can be obtained by using the
expression *ptr.
If a pointer variable points to another pointer
variable, address of first pointer variable is assigned to the second pointer
variable.
For example:
int *ptr1,**ptr2;
int a=100
ptr1=&a;
ptr2=&ptr1;
Where ptr1 is a pointer variable which has the address of the variable a, which
points to an integer value of 100. The variable ptr2 is also a pointer, which
has the address of ptr1. The variables **ptr1, *ptr1 and a represents the value
of 100.
0 Comment "Illustrate about pointer to pointer in detail."
Post a Comment