bool list::remove (char * key)
{
char id[100];
cin.get(key, 100 );
cin.ignore(1, '\n');
//cin >> key; //remove data from the list if it exists
node * prev = NULL;
node * curr = headbyName;
while (curr)
{
curr->item.getName(id);
if(strcmp(key, id) == 0)
{
if(!prev)
headbyName = curr->next;
else
prev->next = curr->next;
delete curr;
size--;
return true;
}
prev = curr;
curr = curr->next;
}
return false;
}
i am cmp a character string to a name of character strings, and if they compare
it will delete it ,but if the name contains "john williams" versus john,williams,
it willl not delete the name... i am not sure why??