https://www.cnblogs.com/komean/p/11109555.html
/* 用x替换a */
void replaceAWithX(string str){
int pos;
pos = str.find("a");
while(pos != -1){
// str.length()求字符的长度,注意str必须是string类型
str.replace(pos,string("a").length(),"x");
pos = str.find("a");
}
cout << str << endl;
}
int replace_string(string &strQrNum, char *str)
{
size_t n = strQrNum.find_last_not_of(str);
if (n != string::npos)
{
//strQrNum = strQrNum.erase(n + 1, strQrNum.size() - n);
int m = strQrNum.size() - n;
strQrNum = strQrNum.erase(n, m);
}
n = strQrNum.find_first_not_of(str);
if (n != string::npos)
{
strQrNum.erase(0, n);
}
return 0;
}