I\'ve looked and looked with the debugger and cannot seem to figure out why the IF statement always prints the message.
The IF statement checks to see if yesno != \'
Take the conditional yesno != 'Y' || 'N'
apart. It has two clauses:
yesno != 'Y'
. This is probably a comparison you intended; it checks to see if the char yesno
is inequal to the value 'Y'
.'N'
. This clause evaluates simply to the value 'N'
. As a bool, 'N'
, which is not zero, is considered "true."So you have "(stuff) ||
(always true)". Here "stuff" is yesno != 'Y'
and "always true" is 'N'
. The result will always be true.