带有“NULL"指针的转换说明符“p"的行为是什么? [英] What is the behavior of the conversion specifier `p` with `NULL` pointer?
本文介绍了带有“NULL"指针的转换说明符“p"的行为是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道是否:
void *ptr = NULL;
printf("%p\n", ptr);
总是给出 (nil)
输出吗?
它依赖于标准库实现,还是 C99 标准规范?
Does it depend on standard library implementation, or it's a C99 standard specification?
推荐答案
在我的系统上它产生 (null)
所以我猜它是实现定义的.更一般地说,%p
打印的所有内容都是实现定义的:
On my system it yields (null)
so I guess it's implementation defined. More generally, everything %p
prints is implementation-defined:
7.21.6.1
参数应该是一个指向 void 的指针.指针的值为转换为一系列打印字符,在一个实现定义的方式.
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.
这篇关于带有“NULL"指针的转换说明符“p"的行为是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文