c++去掉首尾空格是参考一篇文章的,但是忘记文章出处了,就略过吧。
去掉首尾空格的代码如下:
1 void trim(string &s) 2 { 3 4 if( !s.empty() ) 5 { 6 s.erase(0,s.find_first_not_of(" ")); 7 s.erase(s.find_last_not_of(" ") + 1); 8 } 9 10 }
c++去掉首尾空格是参考一篇文章的,但是忘记文章出处了,就略过吧。
去掉首尾空格的代码如下:
1 void trim(string &s) 2 { 3 4 if( !s.empty() ) 5 { 6 s.erase(0,s.find_first_not_of(" ")); 7 s.erase(s.find_last_not_of(" ") + 1); 8 } 9 10 }
相关文章: