In C, exit() terminates the calling process without executing the rest code which is after the exit() function.
Now the question is that if we have exit() function then why C11 standard introduced _Exit()? Actually exit() function performs some cleaning before termination of the program like connection termination, buffer flushes etc. The _Exit() function in C/C++ gives normal termination of a program without performing any cleanup tasks. For example it does not execute functions registered with atexit.
// Here the exit_code represent the exit status // of the program which can be 0 or non-zero. // The _Exit() function returns nothing. void _Exit(int exit_code);
Showing difference through programs:
If we replace exit with _Exit(), then nothing is printed.
This article is contributed by Bishal Kumar Dubey. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- Callbacks in C
- _Noreturn function specifier in C
- Nested functions in C
- Why variable name does not start with numbers in C ?
- Octal numbers in c
- Escape Sequences in C
- Line Splicing in C/C++
- Parameter Passing Techniques in C/C++
- Power Function in C/C++
- Pointers in C and C++ | Set 1 (Introduction, Arithmetic and Array)
- Predefined Identifier __func__ in C
- Implicit return type int in C
- What happens when a function is called before its declaration in C?
- exit(), abort() and assert()
- Static functions in C
Improved By : Vishal Vishwakarma