I'm trying to pass an array as a parameter to a function as a reference, and in this function I do operations on that array but I'm not getting it. I do not want you to use define
or const int
for the array 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;
}