This section of code is supposed to display a menu with two options, read the input and go to the corresponding function. If the user enters something other than 1 and 2 the program should warn the user and show the menu to ask user to enter the input again. This process will keep repeating until the user puts the right input.
I'm trying to find a way to repeat the loop only when the user inputs something other than 1 and 2 (so that the user can enter the appropriate response this time).
However, when I use a while loop like this, it loops no matter what the input is.
Any help is much appreciated.
char input;
displayWellDoneMenu();
scanf("%c", &input);
while (input != '1' || input != '2')
{
printf("You must select 1 or 2!\n");
displayWellDoneMenu();
scanf("%c", &input);
rewind(stdin);
system("cls");
}
switch (input)
{
case'1':
additionIntermediate();
break;
case '2':
main();
break;
}