这两个可以去除首尾的空格 /***begin test file***/ #include <iostream> #include <string> int main() { std::string str1 = " hello world! "; std::string trimstring = " "; std::cout << "str = \"" << str1 << "\"" << std::endl; std::cout << "str.find_first_of(' '...
C++中如何去掉std::string对象的首尾空格 /***write by myself***/ /***begin test file***/ #include <iostream> #include <string> int main() { std::string str1 = " hello world! "; std::string trimstring = " "; std::cout << "str = \"" << str1 << "\"" << std::endl;...
// string 简单实现去除字符串左右空格 #include <iostream> #include <string> using namespace std; class StringUtils { public: static void LTrim(string &s) { string drop = " \t"; s.erase(0, s.find_first_not_of(drop)); } static void RTrim(string &s) { string drop = " \t"; s....
// string 简单实现去除字符串左右空格#include <iostream> #include <string> using namespace std; class StringUtils { public: static void LTrim(string &s) { string drop = " \t"; s.erase(0, s.find_first_not_of(drop)); } static void RTrim(string &s) { string drop = " \t"; s.er...