title: C++ FILE without writing to disk
body: <p>I'm using a library that has quite a few functions that write to a <code>FILE</code> but none that seem to conveniently dump the same data to an object in memory.  Is there any way to create a <code>FILE</code> object (or override it) that stores the data in memory instead of writing to disk -- I'd like to avoid the performance hit of opening/writing/reading from files over and over again.</p>
  
  <p><strong>UPDATE:</strong> per Rob's suggestion, trying stringstream:</p>
  
  <pre><code>ss.put(c);
  
  std::string myval = ss.str();
  
  printf("Value: %s\n after writing: %i length %lu\n",myval.c_str(),c, myval.length());
  </code></pre>
  
  <p>But, now trying to get the data (binary) out of the stringstream has me stuck -- how do I grab the binary data I've been adding?</p>