Mail Archives: djgpp/1995/05/06/01:28:48
What's wrong with the fragment below? I've tried it this way, which
results in the menu printing twice on incorrect input, and with option
as an int, which results in an infinite loop when the input character
isn't 0 or 1. scanf _is_ supposed to ignore '\n' in the input,
isn't it?
Thanks,
Jon
char option;
do {
printf("\n Choose one of the following: ");
printf("\n 0 = end program");
printf("\n 1 = test me\n");
printf("\n Enter option: ");
scanf("%c", &option);
} while (option != '0' && option != '1');
--
- Raw text -