string 类成员函数的简单示例(3)

来源:互联网 发布:apache python wsgi 编辑:程序博客网 时间:2024/06/06 05:51
//modified by quanspace/*从string对象中去掉标点符号。要求输入到程序中滴字符串必须含有 * 标点符号,输出结果则是去掉标点符号后的string 对象。 * */# include <iostream># include <string>using namespace std;int main(){string str = "enjoy ?><..coding, enjoy,.*@ playing!";string::size_type i;cout<<"the original string : "<<endl;cout<<str<<endl;        cout<<"delete punctuation of the strings :"<<endl;for(i = 0; i< str.size(); ++i){//ispunc() 是判断字符串中是否有标点符号if(!ispunct(str[i]))cout<<str[i];}cout<<endl;return 0;}