The GNU case range extension allows case ranges in switch statements:
switch (value) {
case 1 ... 8:
printf(\"Hello, 1 to 8\\n\");
break;
If long long range you could do, a bit dirty but,
switch(what) {
case 1:
/* do 1 */
break;
case 2:
/* do 2 */
break;
default:
if (what > 31 && what < 127) {
/* do 32 to 126 */
}
}
The best would probably be to remove the switch for an if all together.
Be extremely strict with nesting. If you want the switch, for some reason, then better then the above would be:
if (value > 31 && value < 127) {
/* Do something */
} else {
switch (value) {
case 1:
...
}
}
Ach, sorry for edit again. This would be cleaner.
if (value > 31 && value < 127) {
/* Do something */
} else if (value > 127 && value < 178) {
} else if ( ...
}
switch (value) {
case 1:
...
}