title: Segmentation fault error occurs for a simple function I have coded
body: <p>Here I just want to define a function which returns the multiplication of matrices, with <code>N</code> arbitrary, I would like to generate a matrix with a <code>new</code> command. When I execute the function I get the error:</p>
  
  <pre><code>Segmentation fault (core dumped)
  </code></pre>
  
  <p>Whenever I assign values to <code>C</code> I have this error, could anybody tell me what happened and how to fix it?</p>
  
  <pre><code>int **multiply(int **A, int **B, int N){
      int **C = new int*[N];
      for (int i = 0; i &lt; N; i++) {
          for (int j = 0; j &lt; N; j++) {
              for (int k = 0; k &lt; N; k++)
                  C[i][j] = C[i][j] + A[i][k] * B[k][j];
          }
      }
      return (C);
  }
  </code></pre>