Home
menubar
rss_feed

Previous Reference C++ Reference <cstdlib> Next Reference




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:








Previous Reference C++ Reference <cstdlib> Next Reference




Home | Reference | Play Games! | Blog | Forum | Site Map | Contact Us


shadow bottom image