title: Matrix multiplication using multiple threads?
body: <p>I am supposed to multiply 2 matrices using threads. Two things: I keep getting 0's when I run the program. I also get message errors(for each, it says "warning: passing argument 1 of 'printMatrix' from incompatible pointer type" on the bolded lines(where I try to print the output). Also to note, the first block that is bolded, I that was my attempt at solving the problem. I think I am close, but I may not be. Can anyone help? Thanks :)
  Output looks like this:
  A=
  1 4
  2 5
  3 6
  B=
  8 7 6
  5 4 3
  A*B=
  0 0 0
  0 0 0
  0 0 0</p>
  
  <pre><code>#include &lt;pthread.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  #define M 3
  #define K 2
  #define N 3
  
  struct v
  {
      int i; //row
      int j; //column
  };
  
  int A[M][K] = {{1,4},{2,5},{3,6}};
  int B[K][N] = {{8,7,6},{5,4,3}};
  int C[M][N];
  
  void *workerThread(void *data)
  {
      int i=((struct v*)data)-&gt;i;
      int j=((struct v*)data)-&gt;j;
      int accumulator = 0;
  
  /*this is where you should calculate the assigned Cell. You will need to use the row(i) of
              A and column[j] of B. Accumulate the result in accumulator */
      **int k;
      for(k=0; k&lt;k; k++)
      {
              accumulator = A[i][k]*B[k][j];
      }
      C[i][j]=accumulator;
      pthread_exit(NULL);**
   }
  
   void printMatrix(int *matrixIn, int rows, int columns)
  {
      int *matrix = matrixIn;
      int i,j;
      for (i=0;i&lt;rows;i++)
      {
  }
  
  int main (int argc, char *argv[])
  {
  
      pthread_t threads[M*N];
      int i,j;
      int counter = 0;
      int numThreadsCreated = 0;
  
      /*the following 5 lines demonstrates how to create 1 thread to calculate C[0][0], you
              will need to create a loop for all of C's cells*/
      struct v *data = (struct v *)malloc(sizeof(struct v));
      data-&gt;i = 0; //assign the row of C for thread to calculate
      data-&gt;j = 0; //assign the column of C for thread to calculate
      pthread_create(&amp;threads[0], NULL, workerThread, data);
      numThreadsCreated++;
  
      /*wait for all the threads to finish before printing out the matrices*/
      for(j=0; j &lt; numThreadsCreated; j++)
      {
              pthread_join( threads[j], NULL);
      }
  
      printf("A=\n");
      **printMatrix(A,3,2);**
      printf("B=\n");
      **printMatrix(B,2,3);**
      printf("A*B=\n");
      **printMatrix(C,M,N);**
      pthread_exit(NULL);
  }
  </code></pre>