0
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??

2
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by C++masterinneed
0

>>"john williams" versus john,williams,
Because they are not the same -- one has a space and the other contains a comma.

lines 4: why are you using variable key there? Shouldn't it be id

0

>>"john williams" versus john,williams,
Because they are not the same -- one has a space and the other contains a comma.

lines 4: why are you using variable key there? Shouldn't it be id

i got it thanks for your help any way!!!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.