i was running this trivial program and whenever i wrote y or e or s it was printing yes! normally, now it doesn't print yes unless i press y only, what's wrong ?
1 2 3 4 5 6 7 8
#include "stdio.h"
#include "conio.h"
void main ()
{
while ( getche() == 'y' && 'e' && 's' )
printf("\nyes!\n");
}
getche() == 'y' && 'e' && 's' means "if (getche() equals 'y') and ('e' does not equal 0) and ('s' does not equal 0)". Neither 'e' nor 's' are equal to zero, therefore by Boolean algebra[1] the expression is equivalent to getche() == 'y'.
Knowing this, how do you need to modify the expression to do what you intend?
i don't know how this worked for me before, but anyway i want the body of loop to be extracted when only the user types y or e or s, no letters else, i want any letter else terminates the program