您的位置:首页 > 编程语言 > C语言/C++

C++ 如何从string中删除一个字符?

2014-09-12 20:45 274 查看
#include #include #include #include using namespace std;int main(){ string str = "abcdfccccefg"; string::iterator new_end = remove_if(str.begin(), str.end(), bind2nd(equal_to(), 'c')); str.erase(new_end, str.end()); cout << str << endl;string abc = "123'''''456";
int nPos = abc.find_first_of( '\'' ); if ( nPos != string::npos ) { abc = abc.substr( 0 , nPos ) + abc.substr( nPos + 1 , -1 ); } //else // break;cout<<abc; return 0;}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  string c++
相关文章推荐