Homework 5: STL

Write a program that opens a file of text and computes an alphabetized list of words with their frequency of occurrence. You can decide whether upper and lower case should be distinguished.

Using G++ include both stl.h, string and fstream.h libraries. Use the stream library to open and read the file. You might want to use an fstream variable which can be associated with a file for both reading and writing. Use seekg(0) when you need to reposition a stream to its first character.

You must use a container taken from STL, for example you can readily do this problem with the vector container. By using the string type you also get many benefits. For example

in >> word; //reads in as string a next word
So the program should open and print a text file verbatim. The file should be at least several hundred words long. Then you should filter the file by removing non-words and punctuation if necessary. Then assign each word that remains to a vector element. Then sort the entries using the stl generic sort(iterator1, iterator2). Finally print the lexicographic result with frequencies of words.

Due Date: In class June 6, 1996.