编写一个程序,读入一个包含标点符号的字符串,将标点符号去除后输出字符串剩余的部分

#include<iostream>
#include<string>
using namespace std;

int main()
{
   string str="atfi,,ie,,,idfi,,,oo";
   decltype(str.size()) n=0;
   for(auto c:str)
   {
       if(!ispunct(c))
       {
           str[n]=c;
           n++;
           continue;
       }
       else
        continue;
   }
   while(n!=str.size())
   str[n++]='\0';
   cout<<str<<endl;
    return 0;
}

运行结果如下:

posted @ 2014-08-02 23:09  Jessica程序猿  阅读(969)  评论(0编辑  收藏  举报