title: c++ streaming into char array?
body: <p>im currently working on a c++ application which is using a c library which needs a callback implemented from my side
  for example the callback is defined as this:</p>
  
  <pre><code>int onWrite(char *what, char *buffer, size_t size, off_t offset);
  </code></pre>
  
  <p>i have std::set which needs to be formated and written into buffer and take care of size and offset where size is buffer's size and offset how many bytes have already been processed</p>
  
  <p>is there a c++ way where i can stream-like into buffer?
  i think about something like this:</p>
  
  <pre><code>SomeSTLStandardStream stream(buffer,size);
  stream.ignore(offset);  // to drop the first n offset bytes
  for(it=dataset.begin();it!=dataset.end() &amp;&amp; stream.buffer_avail()&gt;0;it++)
      stream &lt;&lt; *it &lt;&lt; "|"; // format csv like for example
  </code></pre>
  
  <p>the core question i have is: is there a standard c++ way to grab just a slice of formated/streamed data and write into given buffer?</p>
  
  <p>if not ill have to implement my own</p>
  
  <p>i also had a look at stringstream but it doesnt seem to fit exactly to my needs cause its using its own write buffer instead of mine
  and i dont know how many bytes have already been written to it too and such....</p>
  
  <p>thx</p>