Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that finds all instances of a string in an input text file, replaces them with another string, and writes the result

image text in transcribed

Write a C++ program that finds all instances of a string in an input text file, replaces them with another string, and writes the result to an output file. At the start of the program, prompt the user to input the string that they want to find by printing "Find: " and read the input string. Then, prompt the user to input the replacement string by printing "Replace with:n" and read the input string The following input/output pairs assume that the input text file reads as follows "In C and C++, problems may be faced if two (or more) include files both in turn include the same third file." (a) Find: include Replace with: EXCLUDE Resulting output file: "In C and C++, problems may be faced if two (or more) EXCLUDE files both in turn EXCLUDE the same third file. (b) Find: C++ Replace with: LANGUAGE Resulting output file: "In C and C++, problems may be faced if two (or more) include files both in turn include the same third file." (c) Find: C++, Replace with: LANGUAGE Resulting output file: "In C and LANGUAGE problems may be faced if two (or more) include files both in turn include the same third file." Note: You must write your code in a source file named find replace.cpp. In your code, you must read from a text file named text in.txt and write to a text file named text out.txt You are provided an example input text file to test your code. Use the string type that is accessible when you include . Use cin to read input from the user (make sure to include ). Use file input and output streams to read from and write to the files (make sure to inlude )

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_2

Step: 3

blur-text-image_3

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

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

Students also viewed these Databases questions

Question

List the characteristics of an effective HR strategy.

Answered: 1 week ago

Question

Explain exothermic and endothermic reactions with examples

Answered: 1 week ago

Question

Write a short note on rancidity and corrosiveness.

Answered: 1 week ago

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago