Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

  1. Each word in the file appears only one time in the index, no matter how many times it appears in the file.
  2. The index is presented in "ASCII code order", not the order in which the words are encountered in the input file.
  3. 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.
  4. In your interface file (main.h) include the following libraries (and only these libraries):

    1. #include
    2. #include
    3. #include
    4. #include
    5. #include

Algorithm

The algorithm for creating a keyword index is:

  1. Read a word from the input file
  2. Scan the index and determine if the word is already present in the index
  3. If the word is not already in the index, insert the word in the proper position in the index
  4. Scan the list of lines for the word to determine if the current file line number is already in the list of lines
  5. 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
  6. Repeat until no more words in the file
  7. Here are some additional design requirements for this assignment:

    1. Implement and use at least one struct
    2. Implement and use at least one array of struct
    3. Implement at least one function that uses pass-by-value coupling.
    4. Implement at least one function that uses pass-by-reference coupling.
    5. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design Application Development And Administration

Authors: Michael V. Mannino

3rd Edition

0071107010, 978-0071107013

More Books

Students also viewed these Databases questions

Question

Equilibrium price is always determined by ______and _______.

Answered: 1 week ago

Question

3. Define the attributions we use to explain behavior

Answered: 1 week ago