I am doing a program to ask the user to input a char with my menu
however,if the user input a invalid char,i have to ask him to input again
this is a part of my program:
==============================================
do {
printf("Menu:\n");
printf("(a) Enter two dates, compute the number of days between them\n");
printf("(b) Enter a date, return its day of the week\n");
printf("(c) Enter a month and year, produce a calendar for the month\n");
printf("(q) Quit\n\n");
printf("Which one do you want to do (a/b/c/q)? ");
scanf("%c",&choose);
} while ((choose!='a')&&(choose!='b')&&(choose!='c')&&(cho ose!='q'));
==============================================
and this is the output:
==============================================
Menu:
(a) Enter two dates, compute the number of days between them
(b) Enter a date, return its day of the week
(c) Enter a month and year, produce a calendar for the month
(q) Quit
Which one do you want to do (a/b/c/q)? s <---invalid input
Menu:
(a) Enter two dates, compute the number of days between them
(b) Enter a date, return its day of the week
(c) Enter a month and year, produce a calendar for the month
(q) Quit
Which one do you want to do (a/b/c/q)? Menu:
(a) Enter two dates, compute the number of days between them
(b) Enter a date, return its day of the week
(c) Enter a month and year, produce a calendar for the month
(q) Quit
Which one do you want to do (a/b/c/q)?
==============================================
as above,the menu appears once extra time.......
also,it the user input two char, the menu displays two extra times.....
what is the method to debug this problem?
is that my while loop problem?