1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <fstream>
int main() {
std::ofstream outFile("log.txt", std::ios::app);
if (outFile.is_open()) {
outFile << "Appending this line to the file." << std::endl;
outFile.close();
std::cout << "Successfully appended to the file." << std::endl;
} else {
std::cerr << "Unable to open file" << std::endl;
}
return 0;
}
Back to ofstream