Difference between return and exit in C Language

Source: Internet
Author: User
Tags exit in

1. exit is used to end the program at any time while the program is running. The exit parameter is returned to the OS. The exit function is also called implicitly at the end of the main function. When the exit function is run, it will first execute the function registered by the atexit () function, and then perform some self-cleaning work, refresh all output streams, close all open streams, and close temporary files created using the standard I/O function tmpfile. Exit is to end a process. It will delete the memory space used by the process and return the error message to the parent process. return is to return the function value and exit the function. 2. return indicates the language level. It indicates the return of the Call Stack, while exit indicates the system call level. It indicates the end of a process. 3. The exit function exits the application and returns a state of the application to the OS. This State identifies some running information of the application. It is related to machines and operating systems. Generally, 0 indicates normal exit. If not 0 indicates abnormal exit. The void exit (int status) function prototype is abnormal. (The header file stdlib. h) 4. return indicates a function call. If the main function is returned, exit indicates that the program is forcibly exited at the call. Once the program is run, it ends.

Related Article

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.