Exit and return

Source: Internet
Author: User
Tags terminates
Function name: Exit () header file: Stdlib.h (if the conversation file for "VC6.0" is: windows.h) feature: Closes all files and terminates the process being executed. Exit (1) indicates an exception exit. This 1 is returned to the operating system. Exit (x) (x not 0) indicates that an exception exit exit (0) indicates that the parameters for normal exit exit () are passed to some operating systems, including Unix,linux, and Ms DOS for use by other programs. Stdlib.h:void exit (int status); parameter: status//Program exit return value the difference between exit () and return: According to ANSI C, the effect of using return and exit () in the original invocation of main () is the same. Note, however, that this is called "initial invocation." If main () is in a recursive program, exit () still terminates the program, but return transfers control to the previous level of recursion until the first level, at which point the return terminates the program. Another difference between return and exit () is that even if you call exit () in a function other than main (), it terminates the program. The difference between _exit () and exit: Header file: Exit: #include <stdlib.h>_exit: #include <unistd.h>_exit () function: direct the process to stop running, clear the memory space it uses. and destroys its various data structures in the kernel; the exit () function makes some packaging on these bases, adding a number of operations before the exit is executed. The most important difference between the exit () function and the _exit () function is that the exit () function checks the opening of the file before calling the exit system, and writes the contents of the file buffer back to the file.

Exit and return

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.