Okay, so this is a part of my program which is basically a recurring error message to the user until a valid input is fed. So basically the issue I'm facing is that whenever I enter a number that is invalid (such as 0, 12 or a negative number), nothing will output and the program will await another input, only then will it identify the input as an error or a valid input. This is not a problem when a symbol or alphabet is input. Is there any workaround I can use?
while (Choice1 < 1 || Choice1 > 11)
{
if(!(cin >> Choice1), Choice1 < 1 || Choice1 > 11)
{
cin.clear();
cin.ignore(512, '\n');
cout << "\n\aError! Please enter a valid input!" << endl;
cout << "Now please enter the first code: ";
cin >> Choice1;
}
}