bool basic_fstream<C,T>::is_open() const;
#include <fstream>
#include <iostream>
#include <fstream>
int main() {
using namespace std;
basic_fstream<char> qXoaXFile;
// Open an ASCII text file for reading and writing.
qXoaXFile.open("XoaX.txt", ios_base::out | ios_base::in | ios_base::trunc);
if (qXoaXFile.is_open()) {
// Write the string into the file
qXoaXFile << "XoaX.net" << endl;
// Set the reading location to the beginning of the file
qXoaXFile.seekg(0);
// Read the file back out
cout << "Read from file: " << qXoaXFile.rdbuf() << endl;
qXoaXFile.close();
} else {
cout << "\"XoaX.txt\" failed to open" << endl;
return -1;
}
// Keep the window open
cin.get();
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.