64,676
社区成员
发帖
与我相关
我的任务
分享
string str("ab'defg");
string::iterator it;
for (it =str.begin(); it != str.end(); ++it)
{
if ( *it == '\'')
{
str.erase(it);
}
}
string abc = "123'456";
while( 1 )
{
int nPos = abc.find_first_of( '\'' );
if ( nPos != string::npos )
{
abc = abc.substr( 0 , nPos ) + abc.substr( nPos + 1 , -1 );
}
else
break;
}
这个东西办法很多的,并不一定要使用迭代器,但是如果会用的话还是使用迭代器效率好一些