// writing on a text file
#include <iostream>
#include <fstream>
usingnamespace std;
int main () {
ofstream myfile ("example.txt"); //creating a stream
if (myfile.is_open()) //opening file and writing data
{
myfile << "This is a line.\n";
myfile << "This is another line.\n";
myfile.close(); //closing file
}
else cout << "Unable to open file";
return 0;
}