/*
   Reading from a file. (first create with writingfile.cpp)
   
   1) What if the file does not contain integers?? Try chaning int to double.

   2) Try reading two integers a,b, simultaneously and printing them
  
   See Nyhoff Chapter 11 for streams.
       Nyhoff P. 116-118 for assert()

*/

#include <fstream>            // ifstream
#include <iostream>           // cout
#include <cassert>            // assert
#include <filesystem>         // current_path

using namespace std;

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


  ifstream fi("test.out");          // Attempt to open file.
  assert( fi.is_open() );           // Halts if file couldn't be opened
   
  int a;
  while (fi >> a)                    // while file contains data
      {
         cout << a << endl;          // print it out
      }
   
/*
  int a,b;
  while (fi >> a >> b )                    // while file contains data
      {
         cout << a << "  " << b << endl;          // print it out
      }
*/

   fi.close();                       // Close file when we have reached the end of it.

   
   
   


}
