title: Coding a basic multi-threaded program
body: <p>I want to create 2 threads, one does the max and one gives the average of a list of numbers entered in the command line.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;pthread.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;limits.h&gt;
  
  void * thread1(int length, int array[] )
  {
  
  int ii = 0;
  int smallest_value = INT_MAX;
          for (; ii &lt; length; ++ii)
          {
                  if (array[ii] &lt; smallest_value)
                  {
                          smallest_value = array[ii];
                  }
          }
   printf("smallest is: %d\n", smallest_value);
  
  
  }
  
  void * thread2()
  {
  
    printf("\n");
  
  }
  
  int main()
  {
    int average;
    int min;
    int max;
  
    int how_many;
    int i;
    int status;
    pthread_t tid1,tid2;
  
    printf("How many numbers?: ");
    scanf("%d",&amp;how_many);
    int ar[how_many];
    printf("Enter the list of numbers: ");
    for (i=0;i&lt;how_many;i++){
    scanf("%d",&amp;ar[i]);
    }
  
  //for(i=0;i&lt;how_many;i++)
  //printf("%d\n",ar[i]);
  
          pthread_create(&amp;tid1,NULL,thread1(how_many,ar),NULL);
          pthread_create(&amp;tid2,NULL,thread2,NULL);
          pthread_join(tid1,NULL);
          pthread_join(tid2,NULL);
          return 0;
    exit(0);
  }
  </code></pre>
  
  <p>I just made the first thread, which is to print out the min. number, but I have the following errors when compiling:</p>
  
  <pre><code>How many numbers?: 3
  Enter the list of numbers: 1
  2
  3
  Smallest: 1
  Segmentation fault
  </code></pre>
  
  <p>How should I go on and fix the seg. fault?</p>