/* This program sorts a list of student records using class BST.

   Input (file):    A list of student records
   Output (screen): The list of student records, sorted so that
                      the last names are in alphabetical order
------------------------------------------------------------------*/

#include <iostream.h>
#include <fstream.h>
#include <stdlib.h>

#include "BST.h"                    // ListElement = Student
#include "Student.h"

int main(void)
{
   BST
      BSTree;                       // an empty tree of students
   Student
      CurrentStudent;               // container for a student
   fstream
      InF("student.dat", ios::in);  // stream to the input file

   if (InF.bad())                   // see if stream is ok
   {
      cerr << "\n*** Main: unable to open input file\n";
      exit (-1);
   }

   InF >> CurrentStudent;           // read the first student

   while (!InF.eof())               // While not eof:
   {
      BSTree.Insert(CurrentStudent);//   insert the student
       InF >> CurrentStudent;       //   read the next student
   }                                // End while

   InF.close();                     // close the input file

   cout << BSTree;                  // view the students

   return 0;
}

