C语言中NULL和NUL的区别

标签: , , ,

很多人混淆C语言中的NULL和NUL,《Expert C Programming》里面有个 Handy Heuristic:

The One ‘l’ nul and the Two ‘l’ null

Memorize this little rhyme to recall the correct terminology for pointers and ASCII zero:

The one "l" NUL ends an ASCII string,

The two "l" NULL points to no thing.

Apologies to Ogden Nash, but the three "l" nulll means check your spelling. The ASCII character with the bit pattern of zero is termed a "NUL". The special pointer value that means the pointer points nowhere is "NULL". The two terms are not interchangeable in meaning.

翻译成中文,就是:

一个‘L’的NUL和两个‘L’的NULL

牢记下面的话,它有助于回忆指针和ASCII码零的正确术语:

一个‘L’的NUL用于结束一个ASCII字符串,

两个‘L’的NULL用于表示什么也不指向(空指针)

当然,如果出现了三个‘L’的NULLL,那就要检查一下有没有拼写错误了。ASCII字符中的'\0'被称为NUL。表示哪里也不指向的特殊的指针值则是NULL。这两个术语不可互换。

赞赏

微信赞赏支付宝赞赏

随机文章:

  1. Ubuntu下安装系统库函数手册
  2. 对VBS效率的再思考——处理二进制数据
  3. OpenWrt路由器WIFI开启13信道
  4. 关闭Windows 7中的ASLR
  5. VBS加密 & VBE解密

2 条评论 发表在“C语言中NULL和NUL的区别”上

  1. 五爷说道:

    这页面被greader一抓之后,格式全乱了。。。
    严重怀疑你是故意的。。

  2. logbird说道:

    NUL 默认 是没定义的 也不能 直接使用 NUL。。。

留下回复