I\'m currently using the following code to right-trim all the std::strings in my programs:
std::strings
std::string s; s.erase(s.find_last_not_of(\" \\n\\r\\
This can be done more simply in C++11 due to the addition of back() and pop_back().
while ( !s.empty() && isspace(s.back()) ) s.pop_back();