title: Resizable char buffer container type for C++
body: <p>I'm using libcurl (HTTP transfer library) with C++ and trying to download files from remote HTTP servers. As file is downloaded, my callback function is called multiple times (e.g. every 10 kb) to send me buffer data.</p>
  
  <p>Basically I need something like "string bufer", a data structure to append <code>char</code> buffer to existing string. In C, I allocate (<code>malloc</code>) a <code>char*</code> and then as new buffers come, I <code>realloc</code> and then <code>memcpy</code> so that I can easily copy my buffer to resized array.</p>
  
  <p>In C, there are multiple solutions to achieve this.</p>
  
  <ol>
  <li>I can keep using <code>malloc</code>, <code>realloc</code>, <code>memcpy</code> but I'm pretty sure that they are not recommended in C++.</li>
  <li>I can use <code>vector&lt;char&gt;</code>.</li>
  <li>I can use <code>stringstream</code>.</li>
  </ol>
  
  <p>My use cases is, I'll append a few thousands of items (<code>char</code>s) at a time, and after it all finishes (download is completed), I will read all of it at once. But I may need options like <code>seek</code> in the future (easy to achieve in array solution (1)) but it is low priority now.</p>
  
  <p>What should I use?</p>