I'm trying to delete from a linked list. But it doesn't seems to be working if i try to delete the first element.
if (found)
{
if (prev == NULL)
{
prev = head;
prev -> next = curr -> next;
delete curr;
}
else
{
prev -> next = curr -> next;
delete curr;
}
}
return found;
The findNode functions works if i were to delete from somewhere in the middle or from the tail. But i figured out that if i delete from the tail, i've have to set the next to NULL, am i right?
findNodefunction? Most important is how you pass (and set) theprevandcurrarguments.prevpoint to to that header node already after a successful search for first node