C language switch statement after the case following the break

 

 

1.case constant expression behind the statement label is actually only play the role, and the role determination condition can not afford, i.e. "just begin at entry label."
Therefore, once the value of the expression in parentheses match Switch back, it started from the label;
and a case back After execution of the statement, if not break statement is encountered, a case will automatically continue into the next, without and then determine whether the match, until it encounters a break statement only stop the execution, exiting the switch statement.
Therefore, if you want to jump out of the switch statement immediately after the implementation of a sub-case, it is necessary to add a final break statement in this branch.

 

Two, switch the default implementation of the order

default is the default statement, whether default position in the front or rear, are the first to judge each case, and finally into default. 

But if each label did not break, will start from the entrance has been executed down until all the statements are completed.


----------------
Disclaimer: This article is CSDN bloggers 'foraging haruko' original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/tiangell/article/details/79006878

Guess you like

Origin www.cnblogs.com/joker-18/p/12132254.html