功能:删除删除字符串中的数字
代码:
#include<iostream>
#include<string>
#include <iterator>
//#include <algorithm>
using namespace std;
int main()
{
string str=("aaaa123bbb"); // 删除字符串中的数字
string::iterator it = str.begin();
while (it != str.end()) {
if ((*it >= '1') && (*it <= '9')) {
it = str.erase(it);
} else { // 必须加else
it++;
}
}
cout << str << endl;
return 0;
}
输出:
版权声明:本文为zy47675676原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。