两者都是指针a
,*a
因此将其打印在格式化输出中,就像printf()
用作%p
格式说明符一样。
否则,您的编译器会收到警告消息
warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type ‘int (*)[2]’
warning: format ‘%x’ expects type ‘unsigned int’, but argument 2 has type ‘int *’
所以试试这个:
printf("%p\n",a);
printf("%p\n",*a);
对于第三种情况**a
是类型int
,所以最好使用%d
或%i
printf("%d\n",**a);
根据C标准,
ISO c99 standard : 7.19.6 Formatted input/output functions
9 If a conversion specification is invalid, the behavior is undefined.
If any argument is not the correct type for the corresponding conversion
specification, the behavior is undefined.