相关疑难解决方法(0)

在switch语句中使用continue

我想从switch语句的中间跳转到以下代码中的循环语句:

while (something = get_something())
{
    switch (something)
    {
    case A:
    case B:
        break;
    default:
        // get another something and try again
        continue;
    }
    // do something for a handled something
    do_something();
}
Run Code Online (Sandbox Code Playgroud)

这是一种有效的使用方式continue吗?continue语句是否忽略了switch语句?C和C++在这方面的行为有何不同?

c c++ continue break switch-statement

74
推荐指数
5
解决办法
9万
查看次数

标签 统计

break ×1

c ×1

c++ ×1

continue ×1

switch-statement ×1