printf
is not showing the element you just saved:
m[i][j] = 0; //Inicializa com 0.
printf("%d",m); //<---aqui
Switch to:
printf("%d",m[i][j]);
The m
is a pointer to pointer, not the number you just saved. To access the number you have to specify the row and column, just as it is in the assignment of 0
.
If the alocarMatriz
function is to be used in main
you should put the return m;
you have commented on, and change the call it has in main
to:
int **matriz = alocarMatriz(Linhas, Colunas);
Do not forget that you also have to release the memory associated with the array when you no longer need it, using the free