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);
buf.erase(buf.size() - 1);
This assumes you know that the string is not empty. If so, you'll get an out_of_range exception.
out_of_range