assume you have a list myList
, and myList.head
points to the first element:
temp = myList.head;
while (temp->next!=NULL){
// do stuff with this element
...
temp = temp->next; // get the next element
}
Now you can go right back and do it again - myList
is still the same, and
temp = myList.head;
gets you right back to the beginning again.