String operation

Please help:
how to delete the last character of a string in C plus plus?

Let’s say you have a strings s;
string s = "xyz69420";
You could do something like
s = s.substr(0, s.size()-1);
Now you should get
s = "xyz6942"

3 Likes

You can use str.pop_back()

2 Likes

Thanks