// Name:  McCabe, Micheal H.
// Date:  March 18, 2009
// Project:   Simple_Calculator_V5
// Filename:  WriteOutputFile.cpp

// File Edit History:
//
// Created on o3/18 before I had the specifications.  Needs to be revised in
// conjunction with the other file routines.

#include "calc_headers.h"
int WriteOutputFile(int start, float data[])
    {  
    int return_value=0;
    int i;
    int records;
    string outputfilename;
    cin.ignore(100, '\n');
    cout << "Please enter a filename to open:  ";
    cin >> outputfilename;
    if (cin)
       {
       cout << "Thank you.  Attempting to open file " << outputfilename << endl;  
       ofstream outputfile;
       outputfile.open(outputfilename.c_str());
       if (outputfile.is_open())
          {
          records=(int)data[0];
          cout << "Writing " << records << " records to disk." << endl;
          outputfile << data[0] << endl;
          for (i=start; i<start+records; i++)
              {
              outputfile << data[i] << endl;
              cout << i << ": " << data[i] << endl;
              }
              outputfile.close();
          }
       }
       else
           {
               cout << "Error.  Output file could not be opened! \n";
               return_value=911;
           }           

    return return_value;
    }
