

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
exit() vs _Exit() function in C and C++
In this section we will see what are the differences between exit() and _Exit() in C and C++. In C the exit() terminates the calling process without executing the remaining code which is present after exit() function.
In C++11, one new function is present called _Exit(). So what is the feature of this function? The exit() function performs some cleaning before terminating the program. It clears the connection termination, buffer flushes etc. This _Exit() function does not clean anything. If we test using atexit() method, it will not work.
Let us see two examples where at first we are using exit() function, then in the next
Example
#include<bits/stdc++.h> using namespace std; void my_function(void) { cout << "Exiting from program"; } int main() { atexit(my_function); exit(10); }
Output
Exiting from program
Example
#include<bits/stdc++.h> using namespace std; void my_function(void) { cout << "Exiting from program"; } int main() { atexit(my_function); _Exit(10); }
Output
In this case the output is blank. Nothing has come.
- Related Questions & Answers
- exit() vs _Exit() in C/C++
- return statement vs exit() in main() C++
- exit() function in PHP
- Difference Between exit(0) and exit(1)
- Return Statement vs Exit() in Main() using C++
- What is exit() function in C language?
- exit(), abort() and assert() in C/C++
- Exit Methods in C# Application
- Python Program Exit handlers (atexit)
- How to exit iPhone application gracefully?
- Disable Exit (or [ X ]) in Tkinter Window
- How to exit a process in Node.js?
- What are the differences in die() and exit() in PHP?
- Node.js – process ‘exit’ Event
- How to exit from a Python if clause?
Advertisements