删除str中的大写字母 s.erase()

#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <cctype>
using namespace std;

int main()
{
	string str("HellowoLD");
	for (string::iterator iter = str.begin(); iter != str.end(); iter++) {
		if (isupper(*iter)) {
			iter = str.erase(iter);		//str.erase()返回指向被删除元素之后的元素的迭代器,如删除H,返回指向e的迭代器。
			iter--;
		}
	}

	cout << str;
	return 0;
}
posted @ 2012-12-20 15:00  helloweworld  阅读(457)  评论(0编辑  收藏  举报