开发环境 :VS2008
示例代码:
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
#include <functional>
#include <locale>
#include <cctype>
using namespace std;
inline string& ltrim(string &str) {
string::iterator p = find_if(str.begin(), str.end(), std::not1(ptr_fun<int, int>(isspace)));
str.erase(str.begin(), p);
return str;
}
inline string& rtrim(string &str) {
string::reverse_iterator p = find_if(str.rbegin(), str.rend(), std::not1(ptr_fun<int , int>(isspace)));
str.erase(p.base(), str.end());
return str;
}
inline string& trim(string &str) {
ltrim(rtrim(str));
return str;
}
int main(){
#if _DEBUG
setlocale(LC_ALL, "chs");
#endif