title: How to cast an integer to void pointer?
body: <p>While working with Threads in C, I'm facing the warning</p>
  
  <p>"warning: cast to pointer from integer of different size"</p>
  
  <p>The code is as follows</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;sys/types.h&gt;
  #include&lt;stdlib.h&gt;
  #include&lt;pthread.h&gt;
  void *print(void *id)
  {
   int a=10;
   printf("My thread id is %ld\n",pthread_self());
   printf("Thread %d is executing\n",id);
   return (void *) 42;
  }
  
  int main()
  {
   pthread_t th[5];
   int t;
   int i;
   int status;
   void *ret;
   for(i=0;i&lt;5;i++)
   {
     status=pthread_create(&amp;th[i],NULL,print,(void *)i); //Getting warning at this line
     if(status)
     {
      printf("Error creating threads\n");
      exit(0);
     }
     pthread_join(th[i],&amp;ret);
     printf("---&gt;%d\n",(int *)ret);
   }
   pthread_exit(NULL);
  }
  </code></pre>
  
  <p>Can anybody explain how to pass an integer to a function which receives (void * ) as a parameter?</p>