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

 Write a C++ program that finds all instances of a string

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!