First of all, it's the best to use a memory refresher:
[
^].
However, what you need is not exactly a trim (the method "Trim" is Delphi and .NET is used to remove leading and/or trailing characters from some set of characters, blank character by default; this is not what you want).
If this is a null-terminated strings, you can just write a null character at the position of a last character.
With
std::string
, simply use
resize
to reduce the current size by one, see
http://www.cplusplus.com/reference/string/string/resize/[
^].
—SA