title: How to insert a buffer in a ostream with c++
body: <p>What i'm trying to do is to insert into a stream ( std::ostream ) a buffer .</p>
  
  <p>this buffer is an attribute of my class "AcquiSample"</p>
  
  <p>I made this example very simple for you to understand my problem.</p>
  
  <p>here the definition of the class :</p>
  
  <pre><code>class AcquiSample
  {
    public:
      IQSample * buffer;
  }
  </code></pre>
  
  <p>here's the definition of the struct IQSample :</p>
  
  <pre><code>struct IQSample {
   struct {
      short val;
   }I;
  struct {
      short val;
   }Q;
  }
  </code></pre>
  
  <p>what I want to do is put this buffer with the known size into a stream like that:</p>
  
  <pre><code>std::ostream stream;
  AcquiSample obj;
  stream &lt;&lt; obj.buffer-&gt;I.val &lt;&lt; obj.buffer-&gt;I.val;
  </code></pre>
  
  <p>I think it's not working because it's not copying the data but the pointer adress, what i want is to put the entire buffer into this stream because i'm sending this stream on another computer.</p>
  
  <p>If anyone know how to do this i'd be very thankful.</p>