Question: a mainh header file that contains all compiler directives and...
- A main.h header file that contains all compiler directives and
C++ declarations for your program.
- A main.cpp source code file that contains all of the executable statements for your program. Your main.cpp file may contain the #include for the main.h file but no other #include statements.
The goal of this program is to create a keyword index for a text input file.
A keyword index is a list of all distinct words in the file , and for each distinct work list all of the line numbers in the file where the word appears. Each distinct word should appear only one time in the list, and each distinct line number should appear only one time for each word. In other words, if a word is used more than once on a line, you list the line only one time.
Here are the functional requirements for your program:
- Accepts an input file name from the user
- If the input file can not be opened, display an appropriate message and end the program.
- For each distinct word in the file, display a list of the line numbers where the word appears
- Words in the list should be displayed in alphabetic (ASCII) order, and line numbers for a word should be displayed in ascending order.
- Each distinct word should appear only one time in the list, and each line number should appear only one time for each word.
A word for purposes of this assignment is any sequence of non-whitespace characters delimited by whitespace, i.e. a word is what the stream input operator (<<) reads into a C++ string object. You do not need to worry about identifying English-language words.
You may assume that there are no more than 100 distinct words in the input file, and that the file contains no more than 100 lines. You should make no assumptions about the maximum length of a line - a single line may exceed 232 bytes in length.