title: pthread with unique struct as parameter C
body: <p>I have this piece of code that is giving me trouble.
  I know all the threads are reading the same struct. But I have no idea how to fix this.</p>
  
  <pre><code>#include &lt;pthread.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  typedef struct {
    int a,b;
  } s_param;
  
  void *
  threadfunc(void *parm)
  {
    s_param *param2 = parm; 
    printf("ID:%d and v:%d\n",param2-&gt;a,param2-&gt;b);
    pthread_exit(NULL);
  }
  
  int main(int argc, char **argv)
  {
    pthread_t thread[3];
    int rc=0,i;
    void * status;
  
    for(i=0; i&lt;3 ; ++i){
      s_param param;
      param.b=10;
      param.a=i;
      rc = pthread_create(&amp;thread[i], NULL, threadfunc, &amp;param ); // !!!!
      if(rc){
        exit(1);
      }
    }  
  
    for(i=0; i&lt;3 ; ++i){
      pthread_join(thread[i],&amp;status);
    }
    return 0;
  }
  </code></pre>
  
  <p>output:</p>
  
  <pre><code>ID:2 and v:10
  ID:2 and v:10
  ID:2 and v:10
  </code></pre>
  
  <p>and what I need:</p>
  
  <pre><code>ID:0 and v:10
  ID:1 and v:10
  ID:2 and v:10
  </code></pre>