I am trying to remove trailing whitespaces of a string in a concise/efficient way.
Let's say I have the string:
string input= "2 2 + "
I used this in an attempt to make it input = "2 2+"
std::string::iterator end_pos = std::remove(input.begin(), input.end(), ' ');
input.erase(end_pos, input.end());
cout << input << endl;
However, it removed all the whitespaces.
How would I implement it so it only removes trailing whitespaces?