1/ fstream::open / fstream::close
2#include <fstream> // std::fstream
3
4int main () {
5
6 std::fstream fs;
7 fs.open ("test.txt", std::fstream::in | std::fstream::out | std::fstream::app);
8
9 fs << " more lorem ipsum";
10
11 fs.close();
12
13 return 0;
14}
1#include <iostream>
2#include <fstream>
3using namespace std;
4
5int main () {
6 ofstream myfile;
7 myfile.open ("file.txt");
8 myfile << "Writing to a file.\n";
9 myfile.close();
10 return 0;
11}