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\\
Try this, it works for me.
inline std::string trim(std::string& str) { str.erase(0, str.find_first_not_of(' ')); //prefixing spaces str.erase(str.find_last_not_of(' ')+1); //surfixing spaces return str; }