473,395 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

LinkedList Pointer

consider foll. piece of code.
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.

Nov 15 '05 #1
4 1133

<r.*******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
consider foll. piece of code.
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.
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
Nov 15 '05 #2
<r.*******@gmail.com> wrote:
consider foll. piece of code.
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.


Perhaps this will help.

http://www.inversereality.org/tutori...nkedlists.html
Nov 15 '05 #3
osmium wrote:

<snip>
Perhaps this will help.

http://www.inversereality.org/tutori...nkedlists.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.
Nov 15 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: J Peterman | last post by:
Im having a nightmare trying to understand these nodes and linked lists. I've posted my code for my node.h, node.cpp, linkedlist.h and linkedlist.cpp files in separates replies. Can someone...
10
by: cody | last post by:
Why isn't there a LinkedList in .NET? Was the reason that the mark&sweep GC algorithm has problems with heavily linked data? A LinkedList is very important is you have huge lists and append a...
1
by: r.devaraj | last post by:
Some typo and confusion in previous post (http://groups.google.com/group/comp.lang.c/browse_thread/thread/5e1f7437701250c4/c83fdc9a2d49e9ac?hl=en#c83fdc9a2d49e9ac) made it difficult for me to fetch...
2
by: Justin Crites | last post by:
I have an object which I want to be serializable. I have marked with with . The object only has a single data member, which is a LinkedList<int>. This linked list is a private member and cannot...
2
by: Paminu | last post by:
I am implementing a double-linkedlist in C. I have defined some pointers that points to different locations in my list. Before using the list I will initialize these pointers and when I call...
6
by: Phillip.Ross.Taylor | last post by:
When I designed my application I created an object called "Orderable" which exposes a public property "sequence". Then a few objects inherit from this. I'll just call them ObjectX for the sake...
3
by: huiling25 | last post by:
I don't know why the customer records cannot be inserted into the linked list and the head of the linked list keep pointing to null... //ListNode.java public class ListNode{ private Object...
1
by: daveftl | last post by:
' i made a type that has Element and Pointer, but this so called pointer acts like 'an index , in order to linked to the next node pointer will just increment. Option Explicit Private Type...
1
by: sejong510 | last post by:
MSDN has an example of creating a LinkedList populated with String objects: http://msdn2.microsoft.com/en-us/library/he2s3bh7.aspx But, how would you have a LinkedList of a created class?...
1
by: CaseySimplified | last post by:
I am writing a LinkedList class from scratch without using the already defined LinkedList class. The only thing that doesn't seem to be working is adding removing and getting the last link in the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.