#include<bits/stdc++.h>
using namespace std;
//code in codeblocks
string trim(string s){
if(s.empty())
return s;
s.erase(0,s.find_first_not_of(" "));
s.erase(s.find_last_not_of(" ") + 1);
return s;
}
int main(){
string s = " Hello World!! ";
cout << s << " size:" << s.size()<<"\n";
cout << trim(s) << " size:" << trim(s).size() <<"\n";
return 0;
}
C++实现Trim函数
最新推荐文章于 2023-12-13 09:47:40 发布