“break;” out of “if” statement?

后端 未结 4 800
有刺的猬
有刺的猬 2020-12-09 07:41

Can you break out of an if statement or is it going to cause crashes? I\'m starting to acquaint myself with C, but this seems controversial. The first image is from a book o

4条回答
  •  温柔的废话
    2020-12-09 08:34

    This is actually the conventional use of the break statement. If the break statement wasn't nested in an if block the for loop could only ever execute one time.

    MSDN lists this as their example for the break statement.

提交回复
热议问题