linked list

what is the process to delete everything from a singly linked list.
Like S= 1->2->3->...
I want to remove all the values from S and reuse it again to store new datas.
Read here

http://www.cplusplus.com/forum/beginner/109089/

it will be useful for you.:)
1
2
3
4
5
6
Node *temp = head->next;
while ( temp != NULL ) {
  delete head;
  head = temp;
  temp = temp->next;
}


After this you should be left with only one Node to which head would be pointing.
Topic archived. No new replies allowed.