/* Filename : boostStringTrim.cpp Compiler : Visual C++ 8.0 / ISO C++ (boost) Description : Demo how to boost to trim string Release : 02/22/2007 1.0 */ #include<iostream> #include<string> #include<boost/algorithm/string.hpp>
usingnamespacestd; usingnamespace boost;
int main(){ string s =" hello boost!! "; trim(s); cout<< s <<endl; }
3.使用template(我用GCC编译不通过,用VS2005却可以)
/* Filename : stringTrim1.cpp Compiler : Visual C++ 8.0 Description : Demo how to trim string by other method. Release : 11/18/2006 */ #include<string> #include<iostream> #include<cwctype>