Question
c++)The goals of this assignment are: Create and use functions Implement pass-by-reference and pass-by-value function coupling Use character arrays and the cstring library Use an
c++)The goals of this assignment are:
- Create and use functions
- Implement pass-by-reference and pass-by-value function coupling
- Use character arrays and the cstring library
- Use an array of struct to model a collection
- Use file i/o
The program you need to write in this assignment will prompt the user for an input text file name, and then generate a keyword index for the file. A "keyword index" is a list of every distinct word that appears in the file, followed by the lines in which the word appears. For example, if the input file is:
as01> more input This This This is a line is a line done This line
Then the keyword index would be:
Keyword Index: "This" appears on lines: 1 5 "a" appears on lines: 2 3 "done" appears on lines: 4 "is" appears on lines: 2 3 "line" appears on lines: 2 3 6
Note the following details:
- Each word in the file appears only one time in the index, no matter how many times it appears in the file.
- The index is presented in "ASCII code order", not the order in which the words are encountered in the input file.
- The list of lines for each word is presented in ascending order. Each line appears only once, no matter how many times the word appears on a line.
-
In your interface file (main.h) include the following libraries (and only these libraries):
- #include
- #include
- #include
- #include
- #include
- #include
Algorithm
The algorithm for creating a keyword index is:
- Read a word from the input file
- Scan the index and determine if the word is already present in the index
- If the word is not already in the index, insert the word in the proper position in the index
- Scan the list of lines for the word to determine if the current file line number is already in the list of lines
- If the current file line number is not already in the list of lines, insert the current file line number in the proper position in the list of lines
- Repeat until no more words in the file
-
Here are some additional design requirements for this assignment:
- Implement and use at least one struct
- Implement and use at least one array of struct
- Implement at least one function that uses pass-by-value coupling.
- Implement at least one function that uses pass-by-reference coupling.
- You may not use C++ string objects! Use char arrays (C-Strings) for all strings
Please (no map or auto headings)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started