title: Reverse bytes for 64-bit value
body: <p>I'm trying to reverse the bytes for a 64 bit address pointer for an assignment and have this code:</p>
  
  <pre><code>char swapPtr(char x){
  x = (x &amp; 0x00000000FFFFFFFF) &lt;&lt; 32 | (x &amp; 0xFFFFFFFF00000000) &gt;&gt; 32;
  x = (x &amp; 0x0000FFFF0000FFFF) &lt;&lt; 16 | (x &amp; 0xFFFF0000FFFF0000) &gt;&gt; 16;
  x = (x &amp; 0x00FF00FF00FF00FF) &lt;&lt; 8  | (x &amp; 0xFF00FF00FF00FF00) &gt;&gt; 8;
  return x;
  }
  </code></pre>
  
  <p>But, it just messes everything up. However, a similar function works perfectly for a 64bit long. Is there something different that needs to be done for pointers?</p>
  
  <p>Could the way I'm making the function call be an issue? </p>
  
  <p>For a pointer:</p>
  
  <pre><code>*(char*)loc = swapPtr(*(char*)loc);
  </code></pre>
  
  <p>For a long:</p>
  
  <pre><code>*loc = swapLong(*loc);
  </code></pre>