Syntax
void quick_exit(int val);
Parameter
This method has only one parameter, val, which is an integral value that represents a program's exit state.
- If exit_code is 0 or EXIT SUCCESS, the program has been terminated.
- If the parameter value is non-zero or EXIT FAILURE, the application was not terminated successfully. These functions are called in the reverse order in which they were called.
Return Value
The quick_exit() function had no return value.
Also Read - C++ Interview Questions
Example
Consider the following code snippet :
#include <bits/stdc++.h>
using namespace std;
void func1()
{
cout << "Inside Function 1" << "\n";
}
void func2()
{
cout << " Inside Exit Function 2" << "\n";
}
int main()
{
at_quick_exit(func1);
at_quick_exit(func2);
quick_exit(0);
return 0;
}

You can also try this code with Online C++ Compiler
Run Code
Output:
Inside Exit Function 2
Inside Exit Function 1

You can also try this code with Online C++ Compiler
Run Code
Explanation :
In the above code snippet, the func1 was first registered with the quick_exit() function, but the output displays that func2 is called first, which shows that quick_exit() functions are called in the reverse order in which they were called.
Try and compile with online c++ compiler.
Must Read Dynamic Binding in C++
Frequently Asked Questions
What is the Standard Template Library?
The Standard Template Library is a set of template classes written in C++. that provide common data structures and functions, including lists, stacks, and arrays.
What is the quick_exit() function?
The quick_exit() function is used to terminate a process normally without cleaning up the resources.
In which header file the quick_exit() function is defined?
The stdlib header file defines the quick_exit() function.
What is the return value of the quick_exit() function?
The quick_exit() function had no return value.
Conclusion
In this article, we have extensively discussed the quick_exit() function in C++. The article explains the details of the quick_exit() function in C++.
We hope that this blog has helped you enhance your knowledge regarding the quick_exit() function in C++ and if you would like to learn more, check out our articles on C++. You can refer to our guided paths on the Coding Ninjas Studio platform to learn more about DSA, DBMS, Competitive Programming, Python, Java, JavaScript, etc. To practice and improve yourself in the interview, you can also check out Top 100 SQL problems, Interview experience, Coding interview questions, and the Ultimate guide path for interviews.
Do upvote our blog to help other ninjas grow.
Happy Coding!!