After hours of research, I did not find anything that answered my question, or I could not understand the answer. I want to create a NxN
array of variable size. I did with pointers , but I want to pass it as a parameter between functions, a function to fill, another to manipulate, etc. But it is not working
After creating the array, how do I pass it to another function? And what should be the statement of the other function to receive it?
int main()
{
int **campo;
...
campo = alocaMatriz(altura,largura);
popularMatriz(campo); //???e agora rsrs
outraFuncao(campo);//??!?!?!
}
int alocaMatriz(int linha, int coluna)
{
int i,j;
int **campo = (int**)malloc(linha * sizeof(int*));
for (i = 0; i < linha; i++)
{
campo[i] = (int*) malloc(coluna * sizeof(int));
for (j = 0; j < coluna; j++)
{
campo[i][j] = 0; //Inicializa com 0.
}
}
campo[0][0]=1;//adiciona o agente ao tabuleiro
}
outraFuncao(int **campo){} //?????