【发布时间】:2014-01-17 10:07:38
【问题描述】:
我做了一个程序来从字符串中删除一组字符。我在下面给出了编码here。
void removeCharFromString(string &str,const string &rStr)
{
std::size_t found = str.find_first_of(rStr);
while (found!=std::string::npos)
{
str[found]=' ';
found=str.find_first_of(rStr,found+1);
}
str=trim(str);
}
std::string str ("scott<=tiger");
removeCharFromString(str,"<=");
至于我的程序,我的输出是正确的。好的。美好的。如果我将 str 的值设为 "scott=tiger" ,则在变量 str 中找不到可搜索字符 "
【问题讨论】: