C++primer习题3.10 删除string字符串的标点

#include <iostream>
#include <string>
using namespace std;
char* my_del_dot(string s)
{
	size_t len = s.size();
	char *des = new char[len+1];
	int j = 0;
	for (size_t i = 0; i != len; ++i)
	{
		if (isalpha(s[i]))
		{
           des[j++] = s[i];
		}
	}
	des[j] = '\0';
	return des;
}
int main()
{
    string s;
	cin >> s;
	cout << my_del_dot(s) << endl;
	return 0;
}

posted @ 2011-06-06 11:18  hailong  阅读(698)  评论(2)    收藏  举报