Reputation: 43
I was wondering if current->link->data
data and current->data
provides the same result.
Also another concept what exactly the difference between current
and current->link
in singly linked list?
Upvotes: 0
Views: 362
Reputation: 575
I was wondering if current->link->data data and current->data provides the same result.
May be they provide same data if same data is stored, but these are different locations i.e. if current->data
is data
at current node
then current->link->data
would be data
of next node
. as shown in figure.
struct node
{
struct node *link;
int data;
};
Consider a typical node
of singly linked list, as mentioned above. The member link
points to NULL
initially but later on it points to some other node
. Consider a linked list with some preinserted node
.
And also another concept what exactly the difference between current and current->link in singly linked list?
current
is pointer to current node
while current->link
is pointer to next node
to current node
.
Upvotes: 5