#include #include #include using namespace std; #include "anaword.h" #include "prompt.h" #include "tvector.h" #include "sortall.h" void FindAnagrams(tvector& list) // pre: list contains list.size() elements // post: all anagrams in list printed, one set of anagrams per line { QuickSort(list,list.size()); } int main(int argc, char * argv[]) { tvector list; ifstream input; string filename,word; // use command line argument if it exists, else prompt user if (argc > 1) { filename = argv[1]; } else { filename = PromptString("enter file name "); } input.open(filename.c_str()); if (input.fail()) { cerr << "could not open " << filename << endl; exit(1); } while (input >> word) { list.push_back(Anaword(word)); } cout << endl << "read " << list.size() << " words" << endl; FindAnagrams(list); return 0; }