int generate(int **p, int M, int N, int K)
{
int i, j, m=0;
*p = (int**)malloc(M * sizeof(int*));
if (*p == NULL)
{
printf ("xxx");
exit(0);
}
for (i=0; i < M; i++)
(*p)[i] = (int*)malloc(N * sizeof(int));
if ((*p)[i] == NULL)
{
printf ("xxx");
exit (0);
}
srand(time(NULL));
while (m < K)
{
i = rand()%(M);
j = rand()%(N);
if (*p[i][j] != '*')
{
*p[i][j] = '*';
m++;
}
}
}
Compiler rings on 5 different lines where a *p is located. I just want to create a 2dimensional dynamically alocated matrix and send it to the address(&) of a *pointer on the main code through this function. I stated the function as int instead of void and on the main code i am simply calling it and not inserting it in a variable. If these have anything to do with the errors please tell me, thank you! Also compiler error: "comparison between pointer and integer", "assignment makes integer f pointer without a cast".