Can someone enlighten how to make this work? So now i have a do/while loop with a switch inside. The switch is handled by a int choice and scanf is "%d". But if I write an char symbol different from number like a,b,c... it goes into infinity loop. Changing int to char and %d to %c works but if something wrong is entered the menu repeats x2 and it becomes messy. Sorry for bad english :) With int:
int main() {
 int choice;
    do{
        menu();
        scanf("%d", &choice);
    switch(choice) {
        case 1:
            // 1-vo poduslovie
            ReadSave();
            break;
        case 2:
            // 2-ro poduslovie
            ShowResult();
            break;
        case 3:
            // 3-to poduslovie
            SavetoScreen();
            break;
        case 4:
            // 4-to poduslovie
            PrinttoScreen();
            break;
        case 5: // exit
            return 0;
        default:
            printf("Wrong choice.\n");
    }
}while(choice!=5);
With char:
int main() {
 char choice;
    do{
        menu();
        scanf("%c", &choice);
    switch(choice) {
        case '1':
            // 1-vo poduslovie
            ReadSave();
            break;
        case '2':
            // 2-ro poduslovie
            ShowResult();
            break;
        case '3':
            // 3-to poduslovie
            SavetoScreen();
            break;
        case '4':
            // 4-to poduslovie
            PrinttoScreen();
            break;
        case '5': // exit
            return 0;
        default:
            printf("Wrong choice.\n");
    }
}while(choice!='5');
 
     
    