title: pthread start routine returning an array of ints
body: <p>I'm not familiar with returning things from pthread start routines, so I've come to SO for some assistance.</p>
  
  <p>The start routine will calculate some prime numbers of a given range, store them in an array of ints and then return that array to the main where it will be printed. </p>
  
  <p>If there is a different way to go about accomplishing this, I'd love to hear it! </p>
  
  <p>Here's what I've got:</p>
  
  <pre><code>//start routine
  void *threadCreate(void* arg){
      int threadNumber = threadCount;
      threadCount++;
      Data *data;
      data = (struct Data*)arg;
      int primes[data-&gt;end]; //I don't know how many primes we will have, but I think if I use the end range value as a size it will be more than enough.
      int k = 0; //Index of the int array
      printf("Thread #%d results: ", threadNumber);
      for (int i = data-&gt;start; i &lt;= data-&gt;end; i++){
          if (isPrime(i)){
              printf("%d ", i);
              primes[k] = i;
              k++;
          }
      }
      printf("\n");
      pthread_exit((void*)primes);
  }
  
  //in main, this is where we print our array
  //I don't know the correct way to get this array
  void *retval;
  
  pthread_join(tid, &amp;retval);
  
  //im aware the next part is more than likely incorrect, I am just trying to illustrate what I am trying to do
  
  for (int i = 0; i &lt; len((int [])retval); i++){
     printf("%d ", (int[])retval[i]);
  }      
  </code></pre>