RosettaCodeData/Task/Strip-whitespace-from-a-string-Top-and-tail/C++/strip-whitespace-from-a-string-top-and-tail.cpp
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

15 lines
620 B
C++

#include <boost/algorithm/string.hpp>
#include <string>
#include <iostream>
int main( ) {
std::string testphrase( " There are unwanted blanks here! " ) ;
std::string lefttrimmed = boost::trim_left_copy( testphrase ) ;
std::string righttrimmed = boost::trim_right_copy( testphrase ) ;
std::cout << "The test phrase is :" << testphrase << "\n" ;
std::cout << "Trimmed on the left side :" << lefttrimmed << "\n" ;
std::cout << "Trimmed on the right side :" << righttrimmed << "\n" ;
boost::trim( testphrase ) ;
std::cout << "Trimmed on both sides :" << testphrase << "\n" ;
return 0 ;
}