EverCrest Message Forums
You are not logged in. Login or Register.
Author
Topic: C++ question
Leftover Mog
No, the spelling errors are not intentional
posted 09-06-2006 07:35:12 PM
Im sorry to bug you all, but for some reason the following code just gets me stuck in an endless while loop, i've tried both with | and || and using char and string.

code:

char taxif

cin>>taxif;
while (taxif != 'y' || 'n')
{
cout<<"Please enter a valid command"<<endl;
cin>>taxif;
}


Leftover Mog fucked around with this message on 09-06-2006 at 07:35 PM.

Won't you be my friend

"I don't know that atheists should be considered as citizens, nor should they be considered patriots. This is one nation under God."
-- George Herbert Walker Bush

Inferno-Spirit
Sports Advocate
posted 09-06-2006 08:07:16 PM
'n' is always greater than 0.

while (taxif != 'y' || 'n')

-should be-

while (taxif != 'y' || taxif != 'n')

"He lets the last Hungarian go, and he goes running. He waits until his wife and kids are in the ground and he goes after the rest of the mob. He kills their kids, he kills their wives, he kills their parents and their parents' friends. He burns down the houses they grew up in and the stores they work in, he kills people that owe them money. And like that he was gone. Underground. No one has ever seen him again. He becomes a myth, a spook story that criminals tell their kids at night. 'If you rat on your pop, Keyser Soze will get you.' And nobody really ever believes." - Roger 'Verbal' Kint, The Usual Suspects
Nina
posted 09-06-2006 08:08:57 PM
!= has precedence over ||. 'n' is always true. Loop lasts for ever.
All times are US/Eastern
Hop To: