美文网首页
[C++ Primer] 练习3.10

[C++ Primer] 练习3.10

作者: 和平北路 | 来源:发表于2017-02-28 14:35 被阅读0次
#include <iostream>

using std::string;
using std::cout;
using std::cin;
using std::endl;

int main() {
    string test("hello, this is a test string. ");
    decltype(test.size()) size = 0;
    while (size < test.size()) {
        if (ispunct(test[size])) {
            test.erase(size, 1);
        }
        size++;
    }
    cout << test << endl;
}

相关文章

网友评论

      本文标题:[C++ Primer] 练习3.10

      本文链接:https://www.haomeiwen.com/subject/bspxgttx.html