title: Passing Array as argument to a new thread in C
body: <p>I am attempting to pass an array as an argument to a function in a new thread using pthread_create, is this possible? I have an array of integers and a calculate average method that is called from the create thread method but I cannot seem to pass my array into the method correctly. Here is my code:
      int nums[];</p>
  
  <pre><code>int average;
  
  int size = 0;
  
  
  void *calcAvg(int *nums[]);
  
  int main(int argc, char *argv[]){
      /* initialize an array of the integers to be passed */
      nums[argc - 1];
      for(int i = 0; i &lt; argc - 1; i++){
          nums[i] = atoi(argv[i + 1]);
          size++;
      }
  
      /* Thread Identifier */
      pthread_t avgThread;
  
      pthread_create(&amp;avgThread, NULL, calcAvg, nums);
  
      pthread_join(avgThread, NULL);
  
      printf("average= %d", average);
  }
  
  void *calcAvg(int *nums[]){
      int sum;
      for(int i = 0; i &lt; size; i++){
          sum += nums[i];
      }
      average = sum / (size);
      pthread_exit(0);
  }
  </code></pre>