skazhy skazhy - 1 month ago 17
C++ Question

Remove last character from C++ string

How can I remove last character from a C++ string?

I tried

st = substr(st.length()-1);
But it didn't work.

Answer

For a non-mutating version:

st = myString.substr(0, myString.size()-1);
Comments