what is wrong with this simple program?
This is a simple little menu which doesn't work. After a character is inputted, user input is skipped for the next scanf statement if the loop continues. If response is declared to be int, it works, why doesnt this work for char?
Code:
#include <stdio.h>
int main()
{
char response;
do {
printf("\nMENU (4 to quit)\n");
printf(" :");
scanf("%c",&response);
switch (response) {
case '1': printf("case 1 reached\n");
break;
case '2':
printf("case 2 reached\n");
break;
case '3':
printf("case 3 reached\n");
break;
}
} while(response != '4');
return 0;
}