#include void jsw_flush(void); #define FALSE 0 #define TRUE !FALSE int main(void) { int done; int ch; /* getchar returns int. This is important! */ done = FALSE; printf("Would you like me to send your password to the bad guys?\n"); while(!done) { printf("Enter Y or N (Y/N)"); ch = getchar(); switch(ch) { case 'N': case 'n': printf("Well, then: your password is safe!\n"); done = TRUE; break; case 'Y': case 'y': printf("Okay, sending your password!\n"); done = TRUE; break; default: printf("You must enter a Y or N!\n"); jsw_flush(); } /* end switch */ } /* end while */ return 0; } void jsw_flush(void) { int ch; do ch = getchar(); while (ch != EOF && ch != '\n'); clearerr(stdin); }