> (all unmanaged c++)
I have a char *. I allocate it using:
char * t = new char [ any_size_here];
at some point I want its length to grow to accomodate copying more
characters. What is the best way of doing it?
Also, can I just use std:string instead, and is its string appending very
efficient?
You would have to allocate a new piece of memory that is bigger than the
first one, copy over the data and then delete the first block.
My experience with std::string has been very positive. It has always been
fast enough for me, and it has the advantage that you don't have to worry
about all those allocations and deallocations yourself. It is also well
documented.
I would definitly advise you to use it, and not roll your own unless you
have a very specific need that is not addressed by the std::string
solutions.
--
Kind regards,
Bruno van Dooren
br**********************@hotmail.com
Remove only "_nos_pam"