title: Passing a structure with array of integers through sockets in C
body: <p>I want to pass structure over a socket in C. I read about it here:</p>
  
  <p><a href="https://stackoverflow.com/questions/1577161/passing-a-structure-through-sockets-in-c">Passing a structure through Sockets in C</a></p>
  
  <p>but mine problem is that I have inside of a structure array of integers, and I don't know how can I serialize and deserialize it, any advice?</p>
  
  <pre><code>struct packet{
      int id;
      char buffer[512];
      int array[4];
  }
  </code></pre>
  
  <p>Serialize function , it is working but array of integers is missing</p>
  
  <pre><code>size_t encode_pack(packet pack, char *buf){
  
      size_t pack_len;
      unsigned char *pt = buf;
      *pt++ = (pack.id  &gt;&gt; 24) &amp; 255 ;
      *pt++ = (pack.id  &gt;&gt; 16)&amp; 255;
      *pt++ = (pack.id &gt;&gt; 8) &amp; 255;
      *pt++ = (pack.id &amp; 255);
  
      strcpy(pt,pack.buffer);
      pt += strlen(pack.buffer)+1;
      pack_len = sizeof(pack.id) + strlen(pack.buffer); 
  
      return pack_len;
  
  }
  </code></pre>