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