Hi. So here's the deal, I'm making a linked list program and everything went smoothly, until I added a if else statement in my remove method to try to catch whether a user entered value is in the list and deletes it, or outputs "Value not found" if not found.
The problem is that when I enter a string not found in the list, the program just terminates. I would appreciate if anyone could help.
1. Insert
2. Delete
3. Display
4. Exit
? 1
Enter Value: asd
Inserted: asd
1. Insert
2. Delete
3. Display
4. Exit
? 2
Enter value: d
Process returned -1 (0xFFFFFFFF) execution time: 9.982 s
Press Enter to Continue
I've been at this for the past hour and to no avail, I can't figure out what's wrong.
Suppose that you've got 1 element in your list. counter = 0
1 2 3 4 5 6 7 8
Node *temp = head;
for(x=0; x<=counter; x++) //¿how many times is the loop executed?
{
if(temp->next->data.compare(d) == 0) //¿which element are you looking at?
break;
else
temp = temp->next;
}