Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is for 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

This is for 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: as1> 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.

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 If the word is not already in the index, insert the word in the proper position in the index

3.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

4. Repeat until no more words in the file

MUST USE FUNCTIONS.

MUST USE CHAR ARRAYS, NOT STRINGS

CAN ONLY USE THE FOLLOWING LIBRARIES

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

SO CANNOT USE , or

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

Practical Database Programming With Visual C# .NET

Authors: Ying Bai

1st Edition

0470467274, 978-0470467275

More Books

Students also viewed these Databases questions

Question

Identify the holders of power in the situation. Who has influence?

Answered: 1 week ago

Question

Compare and contrast a forward contract with a futures contract.

Answered: 1 week ago

Question

2. Describe how technology can impact intercultural interaction.

Answered: 1 week ago