C++ Remove punctuation from String

后端 未结 12 2434
天涯浪人
天涯浪人 2020-11-29 07:02

I got a string and I want to remove all the punctuations from it. How do I do that? I did some research and found that people use the ispunct() function (I tried that), but

12条回答
  •  遥遥无期
    2020-11-29 07:42

    Try to use this one, it will remove all the punctuation on the string in the text file oky. str.erase(remove_if(str.begin(), str.end(), ::ispunct), str.end());

    please reply if helpful

提交回复
热议问题