从一个案例跳到默认情况下,switch语句
问题描述:
switch(ch){
case 'a':
//do something, condition does not match so go to default case
//don't break in here, and don't allow fall through to other cases.
case 'b':
//..
case 'c':
//..
case '_':
//...
default:
//
break;
}
在诸如One上面switch语句中我输入的情况下'一',我只有在发生里面的条件打破,否则我要跳转到默认情况。是否有这样做,而不是标签或goto方法的任何其他方式?
In a switch statement like above one I enter case 'a', I break only if the condition inside it occurs, otherwise I want to jump to default case. Is there any other way of doing this rather than labels or gotos?
答
转到
为胜
switch (ch) {
case 'a':
if (1) goto LINE96532;
break;
case 'b':
if (1) goto LINE96532;
break;
LINE96532:
default:
//
break;
}