How to jump out of a C++ code block?

前端 未结 7 800
无人及你
无人及你 2021-01-04 19:22

This is what I would like to do:

{
    ...
    if(condition)
        break;
    ...
}

This works for a loop. I would like something similar

7条回答
  •  别那么骄傲
    2021-01-04 20:12

    This one:

    {
        // ...
    
        if (!condition)
        {
            // ...
        }
    }
    

    This will avoid goto to jump out of a block of code.

提交回复
热议问题