How can I remove last character from a C++ string?
I tried st = substr(st.length()-1); But it didn\'t work.
st = substr(st.length()-1);
With C++11, you don't even need the length/size. As long as the string is not empty, you can do the following:
if (!st.empty()) st.erase(std::prev(st.end())); // Erase element referred to by iterator one // before the end