A pointer to a pointer stores address of another pointer i.e it points to a pointer.
Representation
type** var_name;
type denotes that it points to pointer to a variable of which type.
Datatype of pointer to a pointer is type**
A quick code snippet
Here's a quick code snippet to make you comfortable with the notations
int **p2p,*ptr,a=300;
ptr=&a;
p2p=&ptr;
printf("%p %p %p",ptr,p2p,&p2p);
Here's a quick picture of address and values of different variables.
p2p ptr a
Address 0xbfab60e4 0xbfab60e8 0xbfab60ec
Value 0xbfab60e8 0xbfab60ec 300
p2p------------>ptr---------->a
-> is read as points to and a variable points to another if it stores the address of another.
Value of a can be retreived by **p2p
No comments:
Post a Comment