This is in windows, but I don't believe it's much different than in linux..
Code:
// basic file operations
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream myfile;
myfile.open ("file.txt");
while (1 == 1)
{
myfile << "Writing this to a file.\n";
myfile.close();
}
return 0;
}
Instead of this overwriting "file.txt" every time it runs, i want it to add that line to the next. So if i ran it twice it would be
Writing this to a file.
Writing this to a file.
I'm new to the language and don't know of a way to do it. Thanks.