linked list

Aug 23, 2013 at 11:46am
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.
Aug 23, 2013 at 12:04pm
Read here

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

it will be useful for you.:)
Aug 23, 2013 at 12:05pm
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.