分配动态二维数组问题,求改错!
# include <stdio.h># include <stdlib.h>
int main()
{
void fun(int **p, int x, int y)
{
int i, j;
p = (int **)malloc(x * sizeof(int *));
for (i = 0; i < x; i++)
{
p[i] = (int *)malloc(y * sizeof(int));
for (j = 0; j < y; j++)
{
p[i][j] = i+j;
printf("%5d",p[i][j]);
}
}
}
void funs(int **p, int x)
{
int i, j;
for (i = 0; i < x; i++)
{
free(p[i]);
pArr[i] = 0;
}
free(p);
p = 0;
}
int **p=NULL;
fun(p,4,5);
funs(p,4);
return 0;
}