test_ofstream.cpp

#include <fstream>

using namespace std;

int main(int argc, char** argv)
{
   ofstream myfile;
   myfile.open("sample.txt");
   myfile << "First line\n";
   myfile << "Second line\n";
   myfile.close();

   return 0;
}