How to change the end of std::string?
You mean remove the last part of the string? Use erase
for that.
One way that I could think of is to assign '\0' to all the trailing characters of the string but it would be inefficient to do so if length of string is large.
std::strings are not 0-terminated. Setting their characters to \0
does not make them shorter.