title: How to return an array in c using pthreads?
body: <p>I tried to write a program that a thread returns an array of numbers by passing a random vector to the thread and thread returns 2 times of the vector. 
  The program is running fine put I'm not getting the expected output.
  The code is as follows: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;pthread.h&gt;
  #include &lt;omp.h&gt;
  void *myThreaddouble();
  
  int i,sum[10],first[10]={10,20,30,40,50};
  
  void *myThreaddouble()
  {
  
  int *sum[10];
  for(i=0;i&lt;5;i++)
  {
    sum[i]= first[i] + first[i];
  }    
  
     pthread_exit(sum[i]);
  }
  
  int main()
  {
  
   double total = omp_get_wtime();
  
   printf("This is using PThread\n");
  
    pthread_t tid1;
    pthread_create(&amp;tid1, NULL, myThreaddouble, NULL);
    printf("Double of the vector:-   \n");
    for ( i = 0 ; i &lt; 5 ; i++ )
    {
      printf(" %d\n",(int) sum[i]);
    }
    pthread_join(tid1, sum[i]);
  
    total = omp_get_wtime() - total;
    printf("%lf is time to add\n",total);
    printf("\n");
  
    return 0;
  
  }
  </code></pre>
  
  <p>and the output is as follows:</p>
  
  <pre><code>This is using PThread
  Double of the vector:-   
   0
   0
   0
   0
   0
  0.000188 is time to add
  </code></pre>
  
  <p>Which is not the expected output, so can someone tell me what is the mistake in this code and how to return an array using pthread. In the i should be able to sum all the return values. </p>
  
  <p>I used <code>gcc q.c -lpthread -lrt -fopenmp</code> command to compile this program. </p>
  
  <p>Thank you in advance! </p>