title: Serialization and deserialization of two dimensional float array in C++
body: <p>I have a structure:</p>
  
  <pre><code>struct Desc {
      int rows;
      int cols;
  }
  </code></pre>
  
  <p>and two dimensional float array.</p>
  
  <p>I need to transfer the structure and <code>data</code> through the network. How to serialize/deserialize it correctly?</p>
  
  <p>This is what I do now:</p>
  
  <pre><code>Desc desc;
  desc.rows = 32;
  desc.cols = 1024;
  float data[rows][cols];
  // setting values on array
  char buffer[sizeof(Desc)+sizeof(float)*desc.rows*desc.probes];
  memcpy(&amp;buffer[0], &amp;desc, sizeof(Desc));    // copying struct into the buffer
  memcpy(&amp;buffer[0]+sizeof(Desc), &amp;data, sizeof(float)*rows*probes);    // copying data into the buffer
  </code></pre>
  
  <p>but I'm not sure if this is a correct approach. </p>
  
  <p>Can someone give me some hints how to do this?</p>