quick_exit() function in C++ with Examples

The quick_exit() function is defined in the stdlib header file. The quick_exit() function is used for normal termination of a process without completely cleaning the resources.

  • If val is zero or EXIT_SUCCESS, it shows successful termination of program.
  • If the value is non-zero or EXIT_FAILURE, it shows that the program is not successfully terminated. These functions are called in the reverse order of there calling.

Syntax:

void quick_exit(int val);

Parameter: This method takes a single parameter val which is an integral value that represent the exit status of a program.

Return Value: This function doesn’t returns anything.

Below program illustrate the quick_exit() function in C++:

Example:-

filter_none

edit
close

play_arrow

link
brightness_4
code

// c++ program to demonstrate
// example of quick_exit() function.
  
#include <bits/stdc++.h>
using namespace std;
  
void function1()
{
    cout << "Exit Function 1" << endl;
}
void function2()
{
    cout << "Exit Function 2" << endl;
}
  
int main()
{
    // registering function 
    at_quick_exit(function1);
    at_quick_exit(function2);
  
    quick_exit(0);
    return 0;
}

chevron_right


Output:

Exit Function 2
Exit Function 1


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



Improved By : ManasChhabra2



Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.