Simple solution if you are using C++11. Probably O(1) time as well:
st.pop_back();
For a non-mutating version:
st = myString.substr(0, myString.size()-1);
Simple solution if you are using C++11. Probably O(1) time as well:
st.pop_back();
For a non-mutating version:
st = myString.substr(0, myString.size()-1);