//Programmer: Bo Bayles  Date: 9 November 2004
//File: lab12.cpp         Class: CS54 C
//Purpose: This program demonstrates opening a file. Then it reads
//  from a file into an array, then outputs the array.

#include "fopen.h"
#include <iostream>
using namespace std;

int main()
{
  fstream infile;
  int count = 0;
  int array[20];

  fileopen(infile, "input");

  infile >> array[count];
  while(!infile.eof())
  {
    infile >> array[++count];
    if (infile.eof())
      break;
    //Fix reading past the end of the file by incrementing the counter
    // after reading the last integer.
  }

  for (int j = 0; j < count; j++)
    cout << array[j] << endl;

  cout << endl;

  infile.close();
  return 0;
}

