CSE 333 24su Exercise 12

Due: Wednesday, July 24th by 10:00 am; No late exercises accepted.
Goals: Write a small program using the C++ STL map container and learn how to use C++ streams to read data from a file.

Description: Write a C++ program that reads a text file whose filename is given as a single command-line argument. The program should read and count the individual words in the file, and, after reading the entire file, it should print a list of the words sorted by the words, and the number of times each word appears in the file. Each word should be written on a separate output line with the word appearing first followed by a single space and the number of occurrences.

For example, if the file quotes.txt contains

to be or not to be
to do is to be
to be is to do
do be do be do
then the output of ./ex12 quotes.txt should begin with the following:
be 6
do 5
is 2
...

You should make the following assumptions:

Hints: Take advantage of the C++ STL library; one of the map containers should be particularly useful. For reading files, take a look at the ifstream class.


As usual, your code must:

You should submit your exercise to the course Gradescope.