If you have two ascii characters, say c1 and c2, just convert to an int and do the switch:
Code:
#include <cctype>
int main()
{
char c1, c2;
int invalue;
// stuff here to get the chars
if (!std::isdigit(c1) || !std::isdigit(c2)) {
// do whatever you must for invalid inputs
}
else {
invalue = (c1 - '0') * 10 + (c2 - '0');
switch(invalue) {
case 0: cmd0();
break;
case 3: cmd3();
break;
// other valid cases here
default: // error routine here for invalid input numbers
}
}
}
Does this do it?
Regards,
Dave