I am using C, and tried this code to get the user to decide what to do:
But when I type, say, d in, then the program is supposed to just ask you again, but instead, it asks you twice. That's why I add \b, but it doesn't help. Also, when I type multiple letters, then I end up with it asking to choose an option a lot more.
So, how could I fix this? A certain part of my code accepts anything, but it ends up getting input from the last question.
Code:
while (choice!='a'&&choice!='b'&&choice!='c') {
printf("Please enter a for option 1, b for option 2, or c for option 3.\n");
choice=getchar();
printf("\b");
}
But when I type, say, d in, then the program is supposed to just ask you again, but instead, it asks you twice. That's why I add \b, but it doesn't help. Also, when I type multiple letters, then I end up with it asking to choose an option a lot more.
So, how could I fix this? A certain part of my code accepts anything, but it ends up getting input from the last question.