是否有%P printf的NULL指针总是给(无)? [英] Does printf NULL pointer with %p always give (nil)?
本文介绍了是否有%P printf的NULL指针总是给(无)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不知道是否确实
int *a = NULL;
printf("%p\n", a);
总会给人(无)
输出?它依赖于标准库的实现,或者是C99的标准规范?
Will always gives (nil)
output? Does it depend on standard library implementation, or it's a C99 standard specification?
推荐答案
在我的编译器它产生(空)
所以我想这是实现定义。更一般地,一切%P
打印是实现定义的:
On my compiler it yields (null)
so I guess it's implementation defined. More generally, everything %p
prints is implementation-defined:
7.21.6.1
参数应该是一个指针无效。指针的值是
转换为打印字符的序列,在一个
实现定义的方式。
The argument shall be a pointer to void. The value of the pointer is converted to a sequence of printing characters, in an implementation-defined manner.
这篇关于是否有%P printf的NULL指针总是给(无)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文