I'm using this function to read the input matrix:
void leMatInt(int **M,int linhas,int colunas){
int i, j;
for (i = 0; i < linhas; i++){
for (j = 0; j < colunas; j++){
scanf("%d", &M[i][j]);
//printf("Leu [%d, %d]\n", i, j);
}
}
}
And I'm creating the matrix like this:
scanf("%d", &v1);
int **matriz1=(int **)malloc(v1 * sizeof(int));
for(i = 0;i < v1; i++){
matriz1[i] = (int *)malloc(v1 * sizeof(int));
}
leMatInt(matriz1, v1, v1);
The code works nicely for v1 <= 4, but if I try to input a 5v5 matrix, the code gets runtime error at the function.