We can exit normal execution of a program by calling exit or abort. Normal execution ends with an exit code of zero. We call exit(0); and program exits with a success. However program can also return unexpectedly. These are the situations when program encounters erroneous situations like memory allocation failure or critical calculation errors like divide by zero etc. Programmers prefer calling exit with a proper error code. Windows/Linux has standard error numbers (errno) defined for every categories of errors. Programmers can even return the same error code received from the last system call. This error code will be saved in the process exit status code. Exit using abort is a different process. It raise a SIGABORT to the process and process exits as the default signal action taken by operating system. Process status will be updated accordingly. Parent process can obtain these status code and can decide if process completed successfully or aborted.
Causes an abnormal program termination. Raises the SIGABRT signal and an unsuccessful termination status is returned to the environment. Whether or not open streams are closed is implementation-defined. No return is possible.
Causes the program to terminate normally. First the functions registered by atexit are called, then all open streams are flushed and closed, and all temporary files opened with tmpfile are removed. The value of status is returned to the environment. If status is EXIT_SUCCESS, then this signifies a successful termination. If status is EXIT_FAILURE, then this signifies an unsuccessful termination. All other values are implementation-defined. No return is possible.
About our authors: Team EQA
You have viewed 1 page out of 248. Your C learning is 0.00% complete. Login to check your learning progress.
Questions index C Questions C++ Questions Win32 MFC COM/DCOM DLL Questions
Compilers & Editors
Download Visual Studio Download XCode Download Visual Studio Code Android studio install sdk Eclipse installer Best C compilers IDEs
Development system setup
Windows media creation tool MSDN subscription Ubuntu virtualbox
New updated posts
Why learn C? Draw on printer Free alt softwares