struct node{
int data;
struct node *next;
};
struct node *list; (say the list as 1->2->3)
printf("%d%p",list,&list);
list holds address of node 1. list->next contains address of 2.
&list tells the space allocated for list itself.
i couldn't get what is the value of &(list->next) and what it
signifies?
is it the place where address of 2 is stored??
Why it need to be stored additional to node 2 and how it is got back?
elaborate plz.
Thanks.
Deva.
No. &list gives the address of the pointer named 'list'.
Nothing to do with allocated size(s).
>
> i couldn't get what is the value of &(list->next) and what it
> signifies?
>
> is it the place where address of 2 is stored??
Not it's the place where the pointer 'list->next' is stored. IOW
the address of that pointer. (Pointers not only store addresses,
they occupy addresses.)
>
> Why it need to be stored additional to node 2 and how it is got back?
>
> elaborate plz.
I'm unsure of exactly what that last question means. The pointer 'next'
is made part of the 'struct node' so that the subsequent node can
be accessed. It's the 'link' part of 'linked list'.
-Mike
Perhaps this will help.
http://www.inversereality.org/tutorials/c++/linkedlists.html
<snip>
> Perhaps this will help.
>
> http://www.inversereality.org/tutorials/c++/linkedlists.html
It is more likely to *confuse* people who are trying to learn C seing as
it is C++. I stopped reading when I saw the first block of code provided
is not valid C.
--
Flash Gordon
Living in interesting times.
Although my email address says spam, it is real and I read it.