break,continue,goto,exit()

1.break

Jump out of the current loop or switch statement, and execute the first statement immediately following the loop or switch statement. Essentially a restricted goto statement.

2.continue

Skip the statement after the continue statement in this loop, execute the next loop, and do not exit the loop, but terminate the current loop in advance.

3.goto

The goto statement is an unconditional redirection statement

     goto end; //end只是一个标识符,代表接下来执行end后面的语句      
     语句1;
     语句2;
end: 语句3; //end后面的语句可以为空,但必须有,也就是可以直接写为end: ;
     语句4;

The identifier behind the goto statement is the culprit that leads to the confusion of the process. Excessive use of goto statements and their identifiers will lead to poor readability of the program, making the structure of the program confusing, and it is difficult to understand the execution of the program. what function. Therefore, structured programs need to avoid using goto statements as much as possible, especially goto statement labels; when using goto statements, only forward jumps are allowed in a single-entry single-exit module, and try not to jump backwards, let alone jump crosses Condition.
The goto statement is very applicable in two situations:
1. Jumping out of multiple loops
2. Jumping to a common exit position for processing operations before exiting

4.exit()

The function of the exit() function is to forcibly terminate the execution of the entire program and forcibly return to the operating system. When the parameter of the exit function is 0 (exit(0)), it means that the program exits normally, and when it is not 0, it means that the program exits after some kind of error occurs. When using this statement, you need to call the header file <stdlib.h>

Guess you like

Origin blog.csdn.net/weixin_44941350/article/details/89410081