关于测试代码
#include <stdio.h>
int main()
{
char a[5][3];
printf("a = %p\n", a);
printf("&a[0] = %p\n", &a[0][0]);
printf("&a = %p\n", &a);
printf("*a = %p\n", *a);
return 0;
}
它被编译并以 C 模式(http://ideone.com/KD9Wz1)给出输出:
a = 0xbfd8ea51
&a[0] = 0xbfd8ea51
&a = 0xbfd8ea51
*a = 0xbfd8ea51
使用严格的 C99 模式 ( http://ideone.com/iTACGZ ) 编译时,会导致编译错误:
prog.c: In function ‘main’:
prog.c:7:10: error: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘char (*)[3]’ [-Werror=format]
prog.c:9:10: error: format ‘%p’ expects argument of type ‘void *’, but argument 2 has type ‘char (*)[5][3]’ [-Werror=format]
cc1: all warnings being treated as errors
上面的代码在C99中不是有效的吗?