/*
   Writing to a file.
  
   See Nyhoff chapter 11.
*/

#include <fstream>   
#include <cassert>
#include <filesystem>    // std::filesystem::current_path   in C++ V17

using namespace std;

int main()
{
  cout << "This program is running in:" << endl;
  cout << std::filesystem::current_path() << "\n";     

   ofstream fo("test.out");          // Attempt to open file.
   assert( fo.is_open() );           // Halts if file couldn't be opened
   
   int N=20;
   
   for (int i=0;i<N;i++)
      {
         fo << i << " " << N*i << endl;
      }
   
   fo.close();                       // Close file


/*
   The file has now been saved on the harddisk, and we can load it
   other places in the code, or let other programs handle it.
*/

}
