Speed question regarding 'string' type
Posted on 2005-04-08
I have a method which receives data 1024 bytes at a time. The bytes are received in a 'char' buffer and appended to 'string' using the 'string' class' append() method. If I receive 20MB of data, appending these 1024 byte buffers to the string takes a very long time (at least 5 minutes). I was wondering if there was a more efficient way of doing this without knowing how much memory to allocate for the string (i.e., the 20 MB size is unknown). Perhaps I could use strcat and append two 'char's and once the transmission is complete, copy the 'char' buffer into the string? Should I use something more low level like a bstr?
As always, your help is much appreciated.