title: Multiplying two arrays in C
body: <p>I'm trying to multiply two multidimensional arrays to form a matrix. I have this function. This should work in theory. However, I am just getting 0s and large/awkward numbers. Can someone help me with this?</p>
  
  <pre><code>int **matrix_mult( int **a, int **b, int nr1, int nc1, int nc2 )
  {
      int **c;
      int i,j,k,l;
      c = malloc(sizeof(int *)*nr1);
  
      if (c == NULL){
          printf("Insuff memm");
      }
  
      for(l=0;l&lt;nr1;l++){
          c[l] = malloc(sizeof(int)*nc1);
          if (c[l] == NULL){
              printf("Insuff memm");
          }
  
      }//for loop
  
  
      for (i=0;i&lt;nr1;i++){
          for (j=0;j&lt;nc2;j++){
              for (k=0;k&lt;nc1;k++){
  
                  c[i][j] = (a[i][k]) * (b[k][j]);
      }
      }
      }
          return( c );  
      }
  </code></pre>