//brian jahns
//cs252 1999
//driver for the binary search tree class based off of the binary tree
//class. uses file input/output
#include <iostream.h>
#include "BST.h"
#include "Bintree.h"
#include "Word.h"
#include <fstream.h>
int main()
{
ifstream bob; //declares a infilestream called bob
ofstream bill;
char name[33]; //array to store the file name
char oname[33];
BST<Word> bst1;
Word word1;
char c[101];
cout<<"enter input filename: "; //gets the file name
cin>>name;
cout<<endl;
cout<<"enter output filename: "; //gets the file name
cin>>oname;
cout<<endl;
bob.open(name); //opens the file
if(bob.bad()) //checks to make sure its a good file
{
cerr<<"ground control to major tom: bob is bad, i repeat, bob is bad"
<<endl;
return 1;
}
int i=0;
c[i]='a';
while(c[i]!=EOF)
{
while(c[i]!='\n')
{
while(c[i]!=' ')
bob.get(c[i]);
word1=c;
bst1.Insert(word1);
}
}
bob.close(); //closes the file
bill.open(name); //opens the file
if(bill.bad()) //checks to make sure its a good file
{
cerr<<"ground control to major tom: bill is bad, i repeat, bill is bad"
<<endl;
return 1;
}
bill<<bst1;
bill.close();
return 0;
}