C problem HW6Prob1txt Problem 1 Find and Replace Write a pro
C++ problem
HW6Prob1.txt
Problem 1. Find and Replace Write a program to search for a user defined string in a text file and replace it with another user defined string. From your main function, read a text file and ask the user for the string to search and the string to replace with. Write a programmer defined function that accepts a file stream object and two strings, and searches for the first string in the text file. If there is a match, this function will replace the matched string with a second string. Choose any implementation you desire. Use HW6Probl.txt\' as the input file for this program.Solution
#include <iostream>
#include <fstream.h>
#include <string.h>
int main(){
ostream outFile(\"New.txt\");
istream readFile(\"HW6Prob1.txt\");
string readout;
string search;
string replace;
while(getline(readFile,readout)){
if(readout == search){
outFile << replace;
}
else {
outFile << readout;
}
}
}
