To trim a string in C++ you should use the Boost library. Writing C++ without Boost is no fun. Boost provides great libraries for almost any c++ work and its a proving ground for future revisions of the c++ standard library.
So how do you trim a string in c++ using boost?
#include <iostream> #include <boost/algorithm/string/trim.hpp>
int main(int argc, char * argv[]) {
cout << trim(argv[1]); }
For more information about boost I recommend this book: Beyond the C++ Standard Library: An Introduction to Boost