Try this:
int ch;
...
printf("Input value: \n");
scanf(" %c", &e);
while( (ch = getchar()) != '\n' && ch != EOF); // To eat up all the characters left behind by scanf call including '\n'.
scanf
reads the first character you typed in to e
. The rest of the characters left behind in the buffer is read one by one to ch
by the getchar
in while
loop until it reads \n
. When it reads \n
then condition becomes false
and the loop is terminate. Now your buffer is empty.