How do I change the string-length of an array of char to prevent memory leaks even if/when someone throws an exception?
If what you really want to do is work with strings, don’t use an array of char in the first place, since arrays are evil. Instead use an object of some string-like class. For example, suppose you want to get a copy of a string, fiddle with the copy, then append another string to the end of the fiddled copy.