Look at this code please:
char o,t; cin >> o >> t;
switch (o,t)
{
case 's','g': cout << "Finish"; break;
default: cout << "Nothing";
}
as you can see switch is set for two values, but in case command I can not check for both of them at the same time. What should I do? is there any way?
You cannot do switch for two expressions at the same time. The switch part only compiles because there is a comma operator (which simply evaluates to the second value, in this case
t).Use plain old
ifstatements.