Question
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
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