去除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 }
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 }