#include <fstream> #include <iostream> using namespace std; int main () { char buffer[256]; // open it for output then write to it fstream myfile; myfile.open("test.txt",ios::out | ios::trunc); if (myfile.is_open()) { myfile << "This outputting a line.\n"; myfile.close(); } return 0; }