i was making a menu with 3 int choices, if the input is a wrong int it reprints the menu and the input. The problem is that when instead of an integer the input is a char the program get stuck in an infinite loop, how can i solve this?
#include <stdio.h>
#include <stdlib.h>
int main(){
int menu_choice;
do{
printf("\n\t\t...PHALSOPHOBIA...\t\t");
printf("\n\tMenu\t\n1. Imposta gioco.\n2. Gioca\n3. Termina gioco\n");
scanf("%d", &menu_choice);
switch (menu_choice)
{
case 1:
break;
case 2:
break;
case 3:
break;
default:
printf("Comando errato.\n");
}
}while (menu_choice < 1 || menu_choice > 3);
}