C++ ofstream open()

Description

C++ ofstream open()

#include <fstream.h>
ofstream        fp;/*from  www .  j  a  v  a2s .  co  m*/
void main()
{
   int ctr;
   fp.open("NUMS.1", ios::out);   // Creates a new file.
   if (!fp)
      {  cout << "Error opening file.\n"; }
   else
   {
      for (ctr = 1; ctr < 101; ctr++)
         {  fp << ctr << " "; }
      }
      fp.close();
      return;
}



PreviousNext

Related