title: A dynamic buffer type in C++?
body: <p>I'm not exactly a C++ newbie, but I have had little serious dealings with it in the past, so my knowledge of its facilities is rather sketchy.</p>
  
  <p>I'm writing a quick proof-of-concept program in C++ and I need a dynamically sizeable buffer of binary data. That is, I'm going to receive data from a network socket and I don't know how much there will be (although not more than a few MB). I could write such a buffer myself, but why bother if the standard library probably has something already? I'm using VS2008, so some Microsoft-specific extension is just fine by me. I only need four operations:</p>
  
  <ul>
  <li>Create the buffer</li>
  <li>Write data to the buffer (binary junk, not zero-terminated)</li>
  <li>Get the written data as a char array (together with its length)</li>
  <li>Free the buffer</li>
  </ul>
  
  <p>What is the name of the class/function set/whatever that I need?</p>
  
  <p><strong>Added:</strong> Several votes go to <code>std::vector</code>. All nice and fine, but I don't want to push several MB of data byte-by-byte. The socket will give data to me in few-KB large chunks, so I'd like to write them all at once. Also, at the end I will need to get the data as a simple char*, because I will need to pass the whole blob along to some Win32 API functions unmodified.</p>