Skip to content

Instantly share code, notes, and snippets.

@NewbiZ
Created December 6, 2010 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NewbiZ/730011 to your computer and use it in GitHub Desktop.
Save NewbiZ/730011 to your computer and use it in GitHub Desktop.
Chop trailing characters from a string
void chop( std::string& str, const std::string& whitespaces=" \t\f\v\n\r" )
{
size_t found = str.find_last_not_of( whitespaces );
if ( found!=std::string::npos )
str.erase( found+1 );
else
str.clear();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment