title: Explanation of converting from void* to int in c
body: <p>in my code i have: </p>
  
  <pre><code>int number_compare(void *val1, void *val2) {
      if (*(int*) val1 &lt; *(int*s) val2) {
  </code></pre>
  
  <p>So basically to convert from void* to int i have to cast *(int *).</p>
  
  <p>This works and give me the correct results, could someone please tell me why though or point me to a thread that explains it. I have already looked and cannot find an answer I understand.</p>