NULL 在 C 中总是零吗? [英] Is NULL always zero in C?

查看:33
本文介绍了NULL 在 C 中总是零吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

昨天我面试了一个中级软件工程职位的人,他提到在 C 中,NULL 并不总是零,而且他见过 C 的实现,其中 NULL 不为零.我觉得这很可疑,但我想确定一下.有谁知道他说得对吗?

I was interviewing a guy for a mid-level software engineering position yesterday, and he mentioned that in C, NULL is not always zero and that he had seen implementations of C where NULL is not zero. I find this highly suspect, but I want to be sure. Anyone know if he is right?

(回复不会影响我对这个候选人的判断,我已经向我的经理提交了我的决定.)

(Responses will not affect my judgement on this candidate, I've already submitted my decision to my manager.)

推荐答案

我假设您指的是空指针.它保证比较等于 0.1 但它不必用全零位表示.2

I'm assuming you mean the null pointer. It is guaranteed to compare equal to 0.1 But it doesn't have to be represented with all-zero bits.2

另请参阅有关空指针的 comp.lang.c 常见问题解答.

See also the comp.lang.c FAQ on null pointers.

<小时><子>

  1. 参见 C99,6.3.2.3.
  2. 没有明确的声明;但请参阅 C99 的脚注 7.20.3(感谢评论中的 @birryree).

这篇关于NULL 在 C 中总是零吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆