title: Swap byte 2 and 4 in a 32 bit integer
body: <p>I had this interview question -   </p>
  
  <blockquote>
    <p>Swap byte <code>2</code> and byte <code>4</code> within an integer sequence.
    Integer is a <code>4</code> byte wide i.e. 32 bits</p>
  </blockquote>
  
  <p>My approach was to use <code>char *pointer</code> and a <code>temp char</code> to swap the bytes.
  For clarity I have broken the steps otherwise an character array can be considered.</p>
  
  <pre><code>unsigned char *b2, *b4, tmpc;
  int n = 0xABCD; ///expected output 0xADCB
  b2 = &amp;n;   b2++;  
  b4 = &amp;n;   b4 +=3;
  ///swap the values;
  tmpc = *b2;
  *b2 = *b4;
  *b4 = tmpc;
  </code></pre>
  
  <p>Any other methods?</p>