Header File
stdlib.h
Category
Process Control Routines
Prototype
void exit(int status);
Description
Terminates program.
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 can be, but is not required, to be set with one of the following:
EXIT_FAILURE |
Abnormal program termination; signal to operating system that program has terminated with an error |
EXIT_SUCCESS |
Normal program termination |
Return Value
None.
Example
#include <stdlib.h> #include <stdio.h> int main(void) { int status; printf("Enter either 1 or 2\n"); status = getchar(); exit(status - '0'); /* Note: this line is never reached */ return 0; }
Portability
POSIX |
Win32 |
ANSI C |
ANSI C++ |
+ |
+ |
+ |
+ |
Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
|
What do you think about this topic? Send feedback!
|