Below i have a code that reads a text file and only writes a line to another textfile if it has the word "unique_chars" in it. I also have other garbage on that line such as for example. "column" How can i make it replace the phrase "column" with something else such as "wall"?
So my line would be like <column name="unique_chars">x22k7c67</column>
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ifstream stream1("source2.txt");
string line ;
ofstream stream2("target2.txt");
while( std::getline( stream1, line ) )
{
if(line.find("unique_chars") != string::npos){
stream2 << line << endl;
cout << line << endl;
}
}
stream1.close();
stream2.close();
return 0;
}
<string>replacefunction.