Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that reads words in input file and checks if a substitute word exists in another file. If a substitute word exists,

Write a C++ program that reads words in input file and checks if a substitute word exists in another file. If a substitute word exists, the substitute word is printed. The program also counts how many times substitution occurred. If a word has multiple substitutes only the last substitute is considered.

The program takes two command line arguments: The first is the name of the file containing substitutions, and the second is the name of the file containing words. The program should process the substitution file and then should read the file containing words, apply any replacements indicated and print the result.

How to decide if an input word matches a word in substitution? Here are the rules:

Any leading and trailing punctuation is ignored. Any case difference is ignored.

If the first letter of the word is capital then even substituted word should be capitalized.

Also, all whitespaces should be printed as is.

If two filenames are not provided, print TWO FILENAMES REQUIRED and stop. If file cannot be read print BAD FILENAME and stop

Example,

Words in substitution:

Hi bye

coming going

home school

Input file we process

Hi!!! I'm !!!cOmInG to meet you at Home now.

The output willl be :-

Bye!!! I'm !!!going to meet you at School now.

Number of changes: 3

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

Relational Database Design With Microcomputer Applications

Authors: Glenn A. Jackson

1st Edition

0137718411, 978-0137718412

More Books

Students also viewed these Databases questions

Question

4. Identify cultural variations in communication style.

Answered: 1 week ago