我想借助指针来扫描二维数组,并且已经编写了这段代码,您能告诉我为什么编译器会给出错误吗?我知道如何使用双指针来做同样的事情,我正在试验这个。通过指针的二维数组
#include<stdio.h>
#include<stdlib.h>
int main(void) {
int i,j,n,a,b;
int (*(*p)[])[];
printf("\n\tEnter the size of the matrix in the form aXb\t\n");
scanf("%dX%d",&a,&b);
p=(int (*(*p)[b])[a])malloc(b*sizeof(int (*p)[a]));
for(i=0;i<b;i++) {
p[i]=(int (*p)[a])malloc(a*sizeof(int));
printf("\t\bEnter Column %d\t\n");
for(j=0;j<a;j++)
scanf("%d",&p[i][j]);
}
return 0;
}
它可以帮助列出编译器错误,你知道的。 ;-) – Edmund 2010-09-18 08:55:35
'这个'是什么意思?构造(int(*(* p)[b])[a])??那该怎么办?我的gcc似乎不喜欢那样。 – 2010-09-18 09:04:06
这些是我得到的错误: – n0nChun 2010-09-18 09:13:31