title: how to use threads and array in C
body: <p>the question is:
  to write program with global integer one dimensional array A of size N by a factor M. using threads , the main thread initializes A and M with random integers, creates N threads such that the ith thread finds Ai = M * Ai, and finally prints the array A.</p>
  
  <p>my problem i am having an error with array initialization also  i am not sure about making the threads in correct way.
  i hope i explained my problem clearly.  </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;pthread.h&gt;
  int M;
  int [10] A;
  
  void *run(void *t)
  {
     A[(int)t]=A[(int)t]*M;
     pthread_exit(NULL);
  }
  
  
  int main()
  {
     pthread_t [10] th;
     srand(time(0))%20;
     M=rand();
     int t;
     for(t = 0; t &lt; 10; t++)
     {
       pthread_create(&amp;th[t], NULL, run, (void *)t);
     }
  
     int j;
     for(j=0;j&lt;10;j++)
      A[j]=j;
  
     int i;
     for(i = 0; i &lt; 10; i++)
     {
       pthread_join(th[i], NULL);
       printf("%d:  %d\n", i,A[i]);
     }
  
     printf("Thread main\n");
     pthread_exit(NULL);
  }
  </code></pre>
  
  <p>these are the errors:</p>
  
  <pre><code>que1.c:5: error: expected identifier or ‘(’ before ‘[’ token
  que1.c: In function ‘run’:
  que1.c:9: error: ‘A’ undeclared (first use in this function)
  que1.c:9: error: (Each undeclared identifier is reported only once
  que1.c:9: error: for each function it appears in.)
  que1.c: In function ‘main’:
  que1.c:16: error: expected identifier or ‘(’ before ‘[’ token
  que1.c:17: error: void value not ignored as it ought to be
  que1.c:22: error: ‘th’ undeclared (first use in this function)
  que1.c:27: error: ‘A’ undeclared (first use in this function)
  </code></pre>