Hello. I'm using this constuction to write to file:
#include <iostream>
#include <fstream>
using namespace std;
int main () {
char data [50];
cout << "Enter data\n";
cin >> data;
ofstream file("data.txt");
if (!file) {
cout << "File opening error";
cin.get();
return 1;
}
file << data;
file.close();
cout << "Data writed" << endl;
return 0;
}
But then program overwrites all file. How can i make it to write data to file's ending?