I don't know what's wrong with this program..even I press n or N it exit..I want to repeat if I press n or N.
can someone help me?

10-27-2011

MK27

Quote:

Originally Posted by AndreyS10

..even I press n or N it exit..I want to repeat if I press n or N.
can someone help me?

Because this:

Code:

if (ex=="Y"||"y"){

Means:

if ex=="Y" is true
OR
if "y" is true

"y" is not zero, so the second condition is always true.

Also, " and ' are different. "Y" indicates a string literal, and ex is a c-string, but you cannot compare one such string to another with ==. You can, however, compare single char values, but a char value is single quoted.