15,605,787 members
See more:
What does this line of code do?
C
```p->next->next
```

C
```p->next->data
```

SOrry if i did anything wrong 1st time.
Posted
Updated 4-Jun-13 13:11pm
v2

## Solution 1

```p->next->next
```

In this case we are traversing the linked list.
We are basically navigating two link nodes.
`p->next->data`

Here, we are navigating to the next linked list node and then accessing its data value.

iiREDii 4-Jun-13 9:38am
i made a drawing:http://i39.tinypic.com/a9lpva.png so using that pic tell me where do these 2 lines take me if at first the pointer is at the head of the list.
P.S:dont laugh at my drawing skillz please......
CPallini 4-Jun-13 10:52am
My 5.
Abhinav S 4-Jun-13 22:27pm
Thanks.
[no name] 7-Jun-13 1:13am
My too 5.
Abhinav S 7-Jun-13 5:49am
Thank you.

## Solution 2

Quote:
p->next->next
See it as a two-steps operation:
C
`p->next`

gives you the pointer to the next element of the list, then
C
`(p->next)->next`

gives you the pointer to the element immediately following the next, that is the pointer to the item 'at distance 2'.

Quote:
p->next->data
With a similar argument, you may write
C
`(p->next)->data`

showing you are accessing the `data` member of the next element of the list.

Abhinav S 4-Jun-13 9:45am
5.
iiREDii 4-Jun-13 10:37am
yeah thats where normal logic took me,look at the pic i posted on solution 1 below could you do another pic using arrows to explain me where do both lines take you to?