Got a question. Can the switch-case statement be used with characters(char) inputs?
code:
choice is a user input value that is read from a function. I'm sure that the character is being returned properly from the function, I've used printfs to test it. Here is the error:Code:switch (choice) { case ('A'||'a'): break; case ('S'||'s'): break; case ('M'||'m'): break; case ('E'||'e'): break; case ('N'||'n'): break; default: printf("\aError incorrect selection!!!\n"); }
\Group_R03.cpp(30) : error C2196: case value '1' already used
.\Group_R03.cpp(32) : error C2196: case value '1' already used
.\Group_R03.cpp(34) : error C2196: case value '1' already used
.\Group_R03.cpp(36) : error C2196: case value '1' already used
it looks as it it setting a value of one to all the cases. I'm alittle confused. thanks in advance for any feedback!