title: C++ Byte order in socket programming
body: <p>In C++ we send data using socket on the network. I am aware that we need to use <em>htons()</em> , <em>ntohs()</em> function to maintain byte order <strong>big endian</strong> and <strong>little endian</strong>. </p>
  
  <p>support we have following data to be sent</p>
  
  <pre><code>int roll;
  int id;
  char name[100];
  </code></pre>
  
  <p>This can also be wrapped into struct. </p>
  
  <p>My confusion here is, for <em>roll</em> and <em>id</em>, we can use <em>htons()</em> function. But for the string <em>name</em>, what should and how should we do it? Do we need to use any such function? will it work on every machine like mac, intel and other network?</p>
  
  <p>I want to send all three fields in one packet. </p>