To check for multiple cases, you need different case statements, such as
Code:
case 'a':
case 'A':
...
You can pile a heap of case-statements on the same place, such as if you wanted to convert a hex-number, you could do something like this:
Code:
switch(c) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
num = c - '0';
break;
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
num = c - 'a' + 10;
break;
case 'A':
case 'B':
case 'C':
case 'D':
case 'E':
case 'F':
num = c - 'A' + 10;
break;
case '\0':
return result;
default:
printf("invalid number...\n");
break;
} // switch
result <<= 4;
result += num;
... some sort of loop ...
Note: I'm not suggesting that this is a GOOD way to convert hex-string to binary - just giving it as an example of dealing with multiple case-statements that do the same thing. [Actually, a good compiler should convert this into very similar code to comparing the bounds of digits and 'a' .. 'f', so it shouldn't be too bad - but I don't generally trust compilers to do a really great job unless I've checked it out for this purpose]
--
Mats