M
markpapadakis
I was checking out the C-FAQ and read here (
http://c-faq.com/misc/nonconstcase.html ) that:
" case labels are limited to single, constant, integral expression ".
However, I have been using case with ranges for a long while ( gcc,
VC++) so either the FAQ calls for an update or those two compilers
provide this functionality as an extension.
example;
switch (a)
{
case 1 ... 10:
// code
break;
case 11 ... 50:
// code
break;
case 800:
// code
break;
default:
// code
break;
}
http://c-faq.com/misc/nonconstcase.html ) that:
" case labels are limited to single, constant, integral expression ".
However, I have been using case with ranges for a long while ( gcc,
VC++) so either the FAQ calls for an update or those two compilers
provide this functionality as an extension.
example;
switch (a)
{
case 1 ... 10:
// code
break;
case 11 ... 50:
// code
break;
case 800:
// code
break;
default:
// code
break;
}