0

How to understand/learn linked lists?

I know, I need to use struct and pointers, but it's hard to imagine how there the pointers and structs work..

8th Jan 2017, 2:34 AM
Igor
Igor  - avatar
1 Odpowiedź
+ 1
Each element of the list consists of to variables: One stores a value, the other one is a pointer to the next element of the list. In your program you access the list with a pointer to the first element of the list. To get to the second element in the list you just go to the position that's stored with the first element. This way you can reach every element one after the other. You know you've reached the last element once you get to a NULL pointer.
8th Jan 2017, 2:47 AM
Robobrine
Robobrine - avatar