I know how to write a switch case, type in a char "a" and run case "a"
But is it possible to somehow attach more than one value for what triggers the case?
for instance, instead of case 'a': case a,b,c and make all three chars trigger the case?
I know how to write a switch case, type in a char "a" and run case "a"
But is it possible to somehow attach more than one value for what triggers the case?
for instance, instead of case 'a': case a,b,c and make all three chars trigger the case?
Last edited by mangekyou; 04-02-2019 at 04:19 PM.
Yes, just allow follow-through by putting the relevant code followed by the break after the multiple cases.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
There is an extension on GCC:
But this is not standard...Code:switch (x) { // 'a', 'b', or 'c'... case 'a' ... 'c': dosomething(); break; }