我想借助指針來掃描二維數組,並且已經編寫了這段代碼,您能告訴我爲什麼編譯器會給出錯誤嗎?我知道如何使用雙指針來做同樣的事情,我正在試驗這個。通過指針的二維數組
#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