Advertisement
obernardovieira

Trim a string

Apr 1st, 2014
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main() {
  5.     std::string str("/comando ");
  6.     std::cout << str << "-" << std::endl;
  7.     size_t endpos = str.find_last_not_of(" ");
  8.     if( std::string::npos != endpos ) {
  9.         str = str.substr( 0, endpos+1 );
  10.     }
  11.     std::cout << str << "-" << std::endl;
  12.     return 0;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement