Hi there..
I'm having much trouble in my following program Delete function is not working properly my rest program is working fine (that's what I think only)
Thanks in advance to helping hands
Your Search() function is wrong too. You're setting flag=false if any node in the list doesn't match. I think you'll find that if one node mathes and one node doesn't then it prints the matching node followed by "no record found." To fix this, break out of the loop when you find the matching record. Then after the loop, just check if temp==NULL. If it does then you didnt' find the record.
Oh, use nullptr instead of NULL.
As for delete, I suggest you consider the following cases separately:
- the list is empty.
- You delete the first item in the list
- You delete the nth item in the list
In the last 2 cases, also consider what happens if you delete the last item in the list. Write your code to handle these cases in this order.