2 ms·
Yes, although it's not always your responsibility to do that. Firstly not all strings are on the heap, but ignoring that... If somebody passes you a pointer to
by asveikau 7y ago
Yes, although it's not always your responsibility to do that.
Firstly not all strings are on the heap, but ignoring that... If somebody passes you a pointer to a string and you aren't going to hold onto it for a while, you can just add to the pointer and it's no big deal. But yes, if you own the allocation, you need to keep the old pointer too.