// main.cc P. Conrad, 4/5/05
// Test the Acct_C class, separate from building linked lists.
// In this program, we will just use an array of Acct_C objects.

// This program won't compile... why?

#include "acct.h"
#include "acctList.h"

#include <iostream>
#include <fstream>

using namespace std;


int main(int argc, char *argv[])
{

  if (argc!=2)
    {
      cerr << "Usage: " << argv[0] << " inputFile " << endl;
      return -1;
    }

  ifstream infile(argv[1],ios::in);

  if (!infile)
    {
      cerr << "Could not open " << argv[1] << endl;
      return -2;
    }

  int thisAcctNum;
  char thisName[NAME_MAX];

  AcctList_C acctList; // this line invokes a default constructor

  infile >> thisAcctNum >> thisName;
  while (!infile.eof())
    {
      Acct_C x(thisAcctNum,thisName);
      acctList.addAccount(x);
      infile >> thisAcctNum >> thisName;
    }
  
  cout << "The program read " << acctList.getNumberOfAccounts() 
       << " lines from the file " << endl;
  cout << "Here they are: " << endl;
  
  acctList.printAllAccounts();
  cout << endl;
  
  return 0;

}







