Answer to Question #56109 in C++ for Rebekah
using namespace std;
void replace(string & str, const string & from, const string & to)
int start_pos = 0;
while((start_pos = str.find(from, start_pos)) != str.npos)
str.replace(start_pos, from.length(), to);
start_pos += to.length();
string text, result;
result = text;
replace(result, "_", " ");
cout<<"Orginal text: "<<text<<endl;
cout<<"Result text: "<<result<<endl;
Need a fast expert's response?Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Thank you so much.. I really appreciate it. I'm sorry for not being specific at first. Actually, I have project and the project asked to do hangman game. Firstly, I have to compare the country name with the user guessed letter. But, at the same time I have to display the underscore to represent the hidden country name. Once the user enter one of the correct country name, then how can I replace the underscore with correct letter and correct position?