C/C++拾遗————空指针{NULL/0/(void*)0}与 空字符{null/'0'} 区别

 

 

突然对NULL与null的区别有点疑惑,在网上搜索了一下,查到下面的用法。其实很简单,就如博文标题,空指针可以是NULL,0或者(void*)0,空字符可以是null或者‘0’表示。

 

When the term "null" or "NULL" is casually used, one of several things may be meant:

  1. The conceptual null pointer, the abstract language concept defined in question 1.1 It is implemented with...
  2. The internal (or run-time) representation of a null pointer, which may or may not be all-bits-0 and which may be different for different pointer types. The actual values should be of concern only to compiler writers. Authors of C programs never see them, since they use...
  3. The source code syntax for null pointers, which is the single character "0". It is often hidden behind...
  4. The NULL macro, which is #defined to be "0" or "(void*)0"Finally, as red herrings, we have...
  5. The ASCII null character (NUL), which does have all bits zero, but has no necessary relation to the null pointer except in name; and...
  6. The "null string," which is another name for an empty string ("").  The term "null string" can be confusing in C (and should perhaps be avoided), because it involves a null ('\0') character, but not a null pointer, which brings us full circle...

This article always uses the phrase "null pointer" (in lower case) for sense 1, the character "0" for sense 3, and the capitalized word "NULL" for sense 4.

 

 

参考链接:

http://www.lysator.liu.se/c/c-faq/c-1.html


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值