删除字符串中标点符号

    技术2022-05-11  97

    #include<iostream>

    #include<string>

    using namespace std;

    int main(){ string str; cout << "Please enter a string:"; cin >> str; cout << endl;

     string caps(",./'/"");

     string::size_type pos = 0; while ((pos = str.find_first_of(caps, pos)) != string::npos) {  str.erase(pos, 1); } cout << str << endl; return 0;} 


    最新回复(0)