#include <fstream> ofstream out("test", ios::out); if(!out) { cout << "Error opening file.\n"; return 1; } ifstream in("test", ios::in); if(!in) { cout << "Error opening file.\n"; return 1; }
If an error occurs, the message is displayed and one (1) is returned. However, only ofstream out("test", ios::out); can be compiled and executed ofstream out("test", ios::out); and ifstream in("test", ios::in); without any errors. In any case, a file is created.
Secko
source share