![]() |
![]() |
![]() |
C++ Reference: abort()
abort()
Declaration
void abort();
Description
Immediately aborts the process and returns an exit code of 3.
Example
#include <iostream>
#include <fstream>
#include <cstdlib>
int main() {
using namespace std;
ofstream qOutFile("OutFile.txt");
// Deliberately close the file just to test the error condition
qOutFile.close();
if (!qOutFile.is_open()) {
cerr << "File \"OutFile.txt\" could not be opened." << endl;
abort();
}
return 0;
}
Output:
![]() |
![]() |
![]() |
| Home | | | Reference | | | Play Games! | | | Blog | | | Forum | | | Site Map | | | Contact Us |





