exit
raw OCR
Terminates program.
Defined in header <stdlib.h>
Syntax
#include <stdlib.h>
void exit(int status);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ | ■ |
Remarks
exit terminates the calling process. Before termination, all files are closed, buffered output (waiting to be output) is written, and any registered "exit functions" (posted with atexit) are called.
status is provided for the calling process as the exit status of the process. Typically a value of 0 is used to indicate a normal exit, and a nonzero value indicates some error. It is set with one of the following
EXITSUCCESS Normal program termination.
| EXIT FAILURE | Abnormal program termination; signal to operating system that program has terminated with an error. |
Return value
None.
See also
Example
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
int main(void)
{
int status;
printf("Enter either 1 or 2\n");
status = getchO ;
exit(status - '0'); /* sets DOS error level */
return 0; /* NOTE: This line is never reached */
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/stdlib.h/exit/
· short form /3.1/exit/