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

Recommended Answers

All 2 Replies

>>"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

>>"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!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.