Is there an easy way to check for digits 0-9 with a switch statement? I'm writing a program to check for certain characters as well as digits. Like checking for '\0', 'F' or 'f', and was wondering if there was also a way to check for 0-9 in a similar fashion. I know I can write a program to return true or false if a character is a digit 0-9, but wasn't sure how to use that with one of the cases in a switch statement. Like if I had:
const int lowerBound = 48;
const int upperBound = 57;
bool isDigit(char *digit)
{
if (*digit >= lowerBound && *digit <= upperBound) {
return true;
}
else {
return false;
}
Thanks! }
how I can go
switch (*singleChar) {
case(???):
}