为NULL总是用C零? [英] Is NULL always zero in C?

查看:110
本文介绍了为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 不过,这并不必须重新presented具有全零比特。< SUP> 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常见问题解答参见空指针。



<子>



  1. 见C99,6.3.2.3。

  2. 有没有明确的要求;但看到C99的注脚,7.20.3(感谢在评论@birryree)。

  1. See C99, 6.3.2.3.
  2. There's no explicit claim; but see the footnote for C99, 7.20.3 (thanks to @birryree in the comments).

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

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