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

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());

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注