- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <float.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdarg.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <time.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
C library function - exit()
Description
The C library function void exit(int status) terminates the calling process immediately. Any open file descriptors belonging to the process are closed and any children of the process are inherited by process 1, init, and the process parent is sent a SIGCHLD signal.
Declaration
Following is the declaration for exit() function.
void exit(int status)
Parameters
status − This is the status value returned to the parent process.
Return Value
This function does not return any value.
Example
The following example shows the usage of exit() function.
#include <stdio.h> #include <stdlib.h> int main () { printf("Start of the program....\n"); printf("Exiting the program....\n"); exit(0); printf("End of the program....\n"); return(0); }
Let us compile and run the above program that will produce the following result −
Start of the program.... Exiting the program....
stdlib_h.htm
Advertisements