以下代码如何工作:
#include <stdio.h>
int main()
{
int (*daytab)[13];
int no_leap_year[13] = {0,31,28,31,30,31,30,31,30,31,30,31,30};
daytab = &no_leap_year;
system("Pause");
return 0;
}
而以下会产生错误和警告:
#include <stdio.h>
int (*daytab)[13];
int no_leap_year[13] = {0,31,28,31,30,31,30,31,30,31,30,31,30};
daytab = &no_leap_year;
int main()
{
system("Pause");
return 0;
}
错误信息如下:
error C2040: 'daytab' : 'int' differs in levels of indirection from 'int (*)[13]'
warning C4047: 'initializing' : 'int' differs in levels of indirection from 'int (*)[13]'
我不明白为什么在外面有这些声明会有main()
什么不同。制作daytab
和no_leap_year
本地或外部如何影响它们的数据类型?