#include <iostream>
#include <string>
using namespace std;
void replace(string str, string from, string to)
{
int a = 0;
do
{
a = 0;
for(int i = 0; i < str.length(); i++)
{
if(str[i] == from[0])
{
a = i;
break;
}
}
if(0 == str.compare(a, from.length(), from))
{
str.erase(a, from.length());
str.insert(a, to);
}
}while(a);
cout << str << endl;
}
int main()
{
replace("asdfsdf", "sd", "g");
return 0;
}