去除string前后空格

1 extern void trim(string &s)
2 {
3     if( !s.empty() )
4     {
5         s.erase(0,s.find_first_not_of(" "));
6         s.erase(s.find_last_not_of(" ") + 1);
7     }
8 }

 

posted @ 2021-10-07 11:54  刘朋1102  阅读(148)  评论(0)    收藏  举报