title: Casting void pointer to long type, not pointer long?
body: <pre><code> int cmpLong(void *a, void *b) {
      long aa = (long)a;
      long bb = (long)b;
      return aa - bb;
  }
  </code></pre>
  
  <p>I don't really understand the purpose of this piece of  code what is it comparing? When a void pointer is casted as a long is it an arbitrary number or does it still hold some meaning?</p>
  
  <p>I have re-written the piece of code to allow for comparison between <code>void *a and void *b</code></p>
  
  <p>Here is the code that I have re-written:</p>
  
  <pre><code>int cmpLong(void *a, void *b) {
      // casting void pointers to long pointers
      long *aa = (long*)a;
      long *bb = (long*)b;
      return *aa - *bb;
  }
  </code></pre>
  
  <p>This makes more sense to me but I don't know whether it is doing the same thing as the original code.</p>