title: Optimal way to convert an int into a char array
body: <p>What is the best method (performance) to put an <code>int</code> into a <code>char</code> array?
  This is my current code:</p>
  
  <pre><code>data[0] = length &amp; 0xff;
  data[1] = (length &gt;&gt; 8)  &amp; 0xff;
  data[2] = (length &gt;&gt; 16) &amp; 0xff;
  data[3] = (length &gt;&gt; 24) &amp; 0xff;
  </code></pre>
  
  <p><code>data</code> is a <code>char</code> array (shared ptr) and <code>length</code> is the <code>int</code>.</p>