3
I’m trying to pass as a parameter a matrix for a function as a reference, and in this function do operations in this matrix but I’m not getting. I don’t want you to use define
or const int
for the matrix dimension values because I want these values to change.
#include <stdio.h>
int operacao (int *matriz[], int dim){
int i=0;
int j=0;
for (i=0; i<dim; i++){
for (j=0; j<dim; j++) {
matriz[i][j] = 1;
printf("%d,", matriz[i][j]);
}
}
}
int main () {
int dimencao;
printf ("digite a dimencao da matriz:");
scanf("%d", &dimencao);
int matriz[dimencao][dimencao];
operacao(&matriz,dimencao);
return 0;
}
Thanks for the answer, yours and Isac’s helped me solve the problem.
– sick1