想动态分配二维数组 运行报错
[view@localhost 20110531]$cat 1.c#include<stdio.h>
int main()
{
int a,b,i=3,n=5;
int **p;
p=(int **)malloc(sizeof(int)*i*n);
for(a=0;a<i;a++)
for(b=0;b<n;b++){
p[a][b]=a+b;
printf("p[%d][%d]=%d\n",a,b,p[a][b]);
}
return;
}
[view@localhost 20110531]$cc -o 1 1.c
[view@localhost 20110531]$./1
Segmentation fault (core dumped)
这个程序报了段错误,错在哪?