I have a school project and I'm working on a menu where the users chooses what he wants to do. I want the choice variable to be a char
, not an int
. Can I add multiple chars in a single switch
case? I searched for a solution but I only found one when the value is an int
, not a char
. I tried this but it didn't work:
char choice;
scanf("%c", &choice);
switch(choice)
{
case 'S', 's':
// do something
break;
case 'I', 'i':
// do another thing
break;
default:
printf("\nUnknown choice!");
break;
}