我想知道是否:
void *ptr = NULL;
printf("%p\n", ptr);
总是会给出 (nil)
输出吗?
它是依赖于标准库实现,还是 C99 标准规范?
最佳答案
在我的系统上它产生 (null)
所以我猜它是实现定义的。更一般地说,%p
打印的所有内容都是实现定义的:
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.
关于c - 转换说明符 `p` 与 `NULL` 指针的行为是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10461360/