Skip to content

Instantly share code, notes, and snippets.

@NewbiZ
Created December 8, 2010 22:31
Show Gist options
  • Save NewbiZ/734040 to your computer and use it in GitHub Desktop.
Save NewbiZ/734040 to your computer and use it in GitHub Desktop.
Trim a string
void trim( std::string& str, const std::string& whitespaces=" \t\f\v\n\r" )
{
size_t found = str.find_first_not_of( whitespaces );
if ( found!=std::string::npos )
str.erase( 0, found );
else
str.clear();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment