title: Matrix Multiplication in C always returning 0?
body: <p>I've been trying to do basic matrix calculations in C, but multiplying two matrices together always returns a value of 0. After reading others who had similar problems, I still do not understand why this is happening. Here is the multiplication function:</p>
  
  <pre><code>double** MatrixMultiplication(double** matrixA, double** matrixB,
                                int sizeXA, int sizeYA, int sizeXB, int sizeYB) 
  {
      double** matrixC = MatrixAllocate(sizeXA, sizeYB);
      for (int i = 0; i &lt; sizeXA; i++) {
          for (int j = 0; j &lt; sizeYB; j++) {
              for (int k = 0; k &lt; sizeXA; k++) {
                  matrixC[i][j] += matrixA[i][k] * matrixB[k][j];
              }
          }
      }
      return matrixC;
  }
  </code></pre>
  
  <p>And this is the code for the <code>MatrixAllocate</code> function:</p>
  
  <pre><code>double** MatrixAllocate(int sizeX, int sizeY) {
      double **matrix;
      matrix = (double**)malloc(sizeX*sizeof(double*));
      for (int i = 0; i &lt; sizeX; i++)
          matrix[i] = (double*)malloc(sizeY*sizeof(double));
  
      for (int i = 0; i &lt; sizeX; i++) {
          for (int j = 0; j &lt; sizeY; j++) {
              matrix[i][j] = 0;
          }
      }
      return matrix;
  }
  </code></pre>
  
  <p>Both MatrixA and MatrixB are filled by the user, and when printed they have non-zero data. </p>