I have a doubt about double pointer....I mean pointer to pointer
Here is my code
I'm not showing the actual program....This is for clarifying my doubtCode:#include<stdio.h> #include<stdlib.h> struct list { int num; struct list * link; }; typedef struct list node; void display( node **p ) { node **temp = p; if( **p != NULL ) printf("NOT NULL"); } main() { node *head; display(&head); }
...node *head means it holds address of a variable of type node,so that we can access that variable like this *head ..ie. value at address head
now i am passing address of head to the function....so type of argument is pointer to a pointer.
..ie...void display(node**p)
...
what is the problem with the statement if(**p!=NULL)
*p means value at address p....ie address of pointer variable head...**p means value at address address of pointer variable p....ie.pointer variable..am i right?
But compiler says that its type is node...not node *...what is the problem...Please give a good explanation on double pointers