Conditional Question

I have the following piece of code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
void sender()
{
	char buf[256] ="";


	do{
		cin.getline(buf,256);


		send(s,buf,sizeof(buf),0);
	}while((buf[0] != '-') && (buf[1] != 'q'));

	return;
}


My problem is, that the loop exists when i enter "-q" OR just "-" <- and that shall not be...

My second question was: what was the name of the function to compare the string in buf without checking like i did above?^^...
Last edited on
You want to loop while: ! (buf[0] == '-' && buf[1] == 'q'), which is: buf[0] != '-' || buf[1] = 'q' by DeMorgan's Law, which is different from what you have.

You're probably asking about strcmpi(buf, "-q"). It returns zero on a match.
Last edited on
yay^^...thanks...
Topic archived. No new replies allowed.