Mega Code Archive

 
Categories / C++ Tutorial / File Stream
 

Writing on a text file

#include <fstream.h> int main () {   ofstream examplefile ("test.txt");      if (examplefile.is_open())   {     examplefile << "This is a line.\n";     examplefile << "This is another line.\n";     examplefile.close();   }   return 0; }