Developer Resources’s Weblog

June 12, 2008

C++ How to trim a string

Filed under: c++ — Tags: , , , — developerresources @ 8:11 am

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

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.