trim函数,剔除字符

* Remove surrounding whitespace from a std::string.

* @param s The string to be modified.

* @param t The set of characters to delete from each end

* of the string.

* @return The same string passed in as a parameter reference.

*/

std::string& trim(std::string& s, const char* t = " \t\n\r\f\v")

{

s.erase(0, s.find_first_not_of(t));

s.erase(s.find_last_not_of(t) + 1);

return s;

}

原文:

http://www.cplusplus.com/forum/beginner/50209/

posted @ 2012-12-09 18:16  浪里飞  阅读(217)  评论(0编辑  收藏  举报