Everything in this function works fine. That is if the value actually exists. If you input a value that is not in the list, and you run the program, it crashes. Can anyone help please?
void deltarget (int value)
{
if (front == NULL && tail == NULL)
{
return;
}
else if (front -> next == NULL && front -> prev == NULL)
front = tail = NULL;
else if (front -> item == value)
{
front -> next -> prev = NULL;
front = front -> next;
}
else if (tail -> item == value)
{
tail -> prev -> next = NULL;
tail = tail -> prev;
}
else
{
Node *temp = front;
while(temp -> item != value && temp -> next != NULL)
{
temp = temp -> next;
}
temp -> next -> prev = temp -> prev;
temp -> prev -> next = temp -> next;
delete temp;
}