c++ continue versus break

前端 未结 6 1039
抹茶落季
抹茶落季 2020-12-16 15:02

Which statement will be executed after \"continue\" or \"break\" ?

for(int i = 0; i < count; ++i)
 {
     // statement1                                            


        
6条回答
  •  生来不讨喜
    2020-12-16 15:41

    Continue jumps straight to the top of the innermost loop, where the per-iteration code and continuance check will be carried out (sections 3 and 2 of the for loop).

    Break jumps straight to immediately after the innermost loop without changing anything.

    It may be easier to think of the former jumping to the closing brace of the innermost loop while the latter jumps just beyond it.

提交回复
热议问题