Hello,
am a new member and this is my first posting. Having benefited from lot of posting i decided to join. But currently am trying to solve an exercise and it is proven difficult for me. I have written a program in c++ in linked list but am facing two problems. (1) when i delete an item that is not stored the program hangs and (2) I cannot modify the program to insert the node at the back i can only do it to insert at the front. here is the coding for my program
void del(node **record)
{
char name[20];
node *current, *previous;
current = *record;
cout<<"\n\nEnter name to delete: ";
cin.getline(name,20);
if ( strcmp(current->name,name) == 0) //if the target is the first node
{
*record = current->nextadd;
delete(current);
}
else
{
while ( strcmp(current->name,name) != 0)
{
previous = current;
current = current->nextadd;
}
previous->nextadd = current->nextadd;
cout<<"\n\nDeleted";
delete(current);
}