C++ STL 去掉字符串中指定的字符 

作者: 吴杰 分类: 编程 发布时间: 2016-07-30 12:26

C++ STL 去掉字符串中指定的字符 。

bind2nd 函数要用到头文件functional

#include <functional>

string response = "aaa\r\nbbb\r\n";
string::iterator new_end = remove_if(response.begin(), response.end(), bind2nd(equal_to<char>(), '\r'));
response.erase(new_end, response.end());