如果你只需要引用一个二维数组的行元素,
例如对于二维数组int score[3][4]
是不是会写成
scanf("%d",&score[1]) ;
然鹅
warning: format '%d' expects argument of type 'int *', but argument 2 has type 'int (*)[3]'
出现了error
这是令人崩溃的
实际上,这个问题的解决还需要我们回到指针与数组之间的关系中去
具体详尽的解释我不在这里展开,留个读者自己探索
解决办法是这样的,用下面这个代码就不会有问题
#include <stdio.h>
int main()
{
int score[4][3];
int i;
printf("Please input scores: ");
for(i=0;i<4;i++)
{
scanf("%d",score[i]);
}
printf("\n");
for(i=0;i<4;i++)
{
printf("%d\n",*score[i]);
}
return 0;
}