title: Typecasting to void pointer & back
body: <p>I have a function:</p>
  
  <pre><code>void *findPos(void *param)
  {
     int origPos=(int)param;
     ...
  }
  </code></pre>
  
  <p>Which I am calling as a thread runner:</p>
  
  <pre><code>pthread_create( &amp;threadIdArray[i], NULL, findPos, (void *)i );
  </code></pre>
  
  <p>Now, this way, I get the value of origPos as the typecasted void pointer param, ie. i. This feels like a dirty hack to get around the limitation of being allowed to pass only void pointers to a thread runner function.</p>
  
  <p>Can this be done in a cleaner way?</p>
  
  <p><strong>Edit:</strong></p>
  
  <p>Please note that I run the <code>pthread_create()</code> function in a <code>i</code> for loop, hence passing a pointer to i may not be a safe choice. </p>