Die ()Stop program running and output content
ExitIs to stop the program running, no output content
ReturnYesreturn Value
DieStop only when an error occurs.
ExitIs to stop directly without running the subsequent code, exit () can display the content.
ReturnIt is a pure return value, but it does not run subsequent code.
Exit (0 ):Run the program normally and exit the program;
Exit (1 ):Exit the program due to abnormal operation;
Return ():Returns the function. If it is in the main function, it exits the function and returns a value.
Details:
1. return returns the function value, which is a keyword; exit is a function.
2. return indicates the language level, which indicates the return of the call stack, and exit indicates the system call level, which indicates the end of a process.
3. return indicates the exit of the function (return); exit indicates the exit of the process.
4. return is provided in C language, and exit is provided by the operating system (or provided in the function library ).
5. return ends the execution of a function, and transmits the execution information of the function to other calling functions. The exit function exits the application and deletes the memory space used by the process, return a state of the application to the OS, which identifies some running information of the application. This information is related to the machine and the operating system. Generally, 0 indicates that the application Exits normally, if the value is not 0, the system exits abnormally.
6. Calls from non-main functionsReturnAndExitThe effect is obvious,MainFunction callReturnAndExitIn most cases, the phenomena are consistent.