Click here to Skip to main content
15,945,889 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to delete data from LinkList,
By checking condition that,
is that a first node,or last node ,or inbetween
Resmi Anna 3-Jun-11 3:17am    
Have you already implemented some part of your linked list?
If so you may be keeping a header or root node rt
like 'pHeader' or something.
to check if first node
if(pHeader->data == pCurrentNode->data )
to check if last node
if(pHeader->pNext == NULL )
if both these fail it is a node in b/w.
Do traverse thru node in a loop to update pCurrentNode value.
It would be helpful if you share the code


Please referes the following article, it will help you a lot.

How to create Linked list using C/C++
Share this answer
hakz.code 3-Jun-11 4:34am    
My 5!
LaxmikantYadav 26-Mar-12 15:45pm    
Thanks Harish :)
You know, deleting an item in a linked list is just a matter of updating pointers:
  • find the 'to be deleted' node.
  • set the 'previous' node pointing to the 'next' (and viceversa if the list is double linked).
  • release the allocated memory of the 'deleted node'.

Now the technical deatils for performing such operation depend on the list implementation.
Share this answer
In case of Threads

If multiple threads are accessing the linklist then you will have to take the special care. You will need to use Critical section.
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900