I want to create an array using pointer pointers, however I'm having a hard time passing the parameters. First I dynamically allocate the array using a function. And then I read it. The program compiled, however at the time of reading the values it stops. I think the error is in the parameter pass, but I can not see.
int alocaMatriz(int **matriz, int lin, int col){
int i;
matriz=(int**)malloc(lin*sizeof(int*));
for(i=0;i<col;i++){
matriz[i]=(int*)malloc(col*sizeof(int));
}
}
void leMatriz(int **matriz, int lin, int col){
int i, j;
printf("\nDigite os valores: ");
for(i=0;i<lin;i++){
for(j=0;j<col;j++){
scanf("%d", &matriz[i][j]);
}
}
}
int main(int argc, char** argv) {
int lin, col;
int **matriz;
printf("Digite as dimensoes da matriz: ");
scanf("%d %d", &lin, &col);
alocaMatriz(matriz, lin, col);
leMatriz(matriz, lin, col);
mostraMatriz(matriz, lin, col);
return 0;
}