... 表示范围
case 0...4; // error
case 5 ... 9; // ok
eg 1:
char ch = 4;
switch(ch)
{
case 1: printf(" into 1\n");break;
case 3 ... 8: printf( " into 2 to 8\n");break;
}
out:
into 2 to 8
eg 2:
switch(c)
{
case 'a' ... 'z': 操作 break;
case 'A' ... 'Z': 操作 break;
case '0' ... '9': 操作 break;
case 1:
case 2:
case 3:
操作 break;
default:
操作 break;
case 0...4; // error
case 5 ... 9; // ok
eg 1:
char ch = 4;
switch(ch)
{
case 1: printf(" into 1\n");break;
case 3 ... 8: printf( " into 2 to 8\n");break;
}
out:
into 2 to 8
eg 2:
switch(c)
{
case 'a' ... 'z': 操作 break;
case 'A' ... 'Z': 操作 break;
case '0' ... '9': 操作 break;
case 1:
case 2:
case 3:
操作 break;
default:
操作 break;
}