title: Returning value from a Pthread
body: <p>I have a function shown below which I pass it to pthread_create. I have read plenty of posts and implemented them on my code, However I still can not return a value.</p>
  
  <pre><code>void *threaded_FFT(void* arg) {
      struct arg_struct *data = (struct arg_struct *)arg;
  
      data-&gt;base = data-&gt;fft-&gt;in;
  
      for(i=0;i&lt;N;i++){
          data-&gt;base[i].re =  data-&gt;input[i]; data-&gt;base[i].im =0.0; 
      }
  
      usleep(1);
  
      gpu_fft_execute(data-&gt;fft);
      data-&gt;base = data-&gt;fft-&gt;out;
  
      for(i=0;i&lt;N;i++){
          data-&gt;output[i]= sqrt(((data-&gt;base[i].re)*(data-&gt;base[i].re))+((data-&gt;base[i].im)*(data-&gt;base[i].im))); 
      }
  
      return (void *)data-&gt;output; 
  }   
  </code></pre>
  
  <p>When I add a printf line to display data->output[0...N], I can clearly see that they've proper values which shows function working properly.</p>
  
  <p>I'm trying this in my main function</p>
  
  <pre><code>void *outData;
  ...
  pthread_join(threads[],&amp;outData);
  ...
  printf("%f\n",(float *)outData);
  </code></pre>
  
  <p>This always returns me value of 0.000000</p>