hello, i am really new in C programming. This is regarding switch case. How do i limit user input in switch cases?
In this case, after they input 1 or 2, i dont want them to input any other number other than 0. Im still new in loop so any suggestion?
#include <stdio.h>
#incude<stdlib.h>
main(){
int number;
char Lunch_Dinner_Set[256] = "Lunch/Dinner Set: \n1 Burger/chicken\n1 drink (medium)\n0. Back to Menu";
char Breakfast_Set[256] = "Breakfast Set:\n1 breakfast\n1 drink (medium)\n\n0. Back to Menu";
char Menu[256]= "\n1. Lunch/Dinner Det\n2. Breakfast Set\n9. exit\nSelect Menu: ";
printf("%s", Menu);
scanf("%d", &number);
system("cls");
do
{ switch (number){
case 0: printf("%s\n", Menu); break;
case 1:printf("%s\n", Lunch_Dinner_Set); break;
case 2: printf("%s\n", Breakfast_Set); break;
case 9: exit(1); break;
default: printf("Invalid"); break;
}
} while(
scanf("%d", &number)+
system("cls"));
}