it's really ridiculous when I try to test my code today
I had never known there are some key word or syntax about "nil" in C/C++, to make it clear I duplicate it in the following test code:
/* nil.c by vinco at 2011-08-03
* os : ubuntu 9.10
* compiler :CC/GCC
*/
#include<stdio.h>
int main()
{
char* p = NULL;
printf("\n");
printf("p = %p\n",p);
printf("p = %s\n",p);
printf("\n");
return 0;
}
compile and run it:
root@vinco:/home/vinco# make nil
cc nil.c -o nil
root@vinco:/home/vinco# ./nil
p = (nil)
p = (null)
root@vinco:/home/vinco#
I search it in Google and Baidu, it's seem that "nil" is same with NULL to some extent , means no value.
does that the truth ?
I would appreciate it if you could explain it clearly for me !!!
理解C/C++中关于'nil'的含义与使用
本文探讨了C/C++编程语言中关键字'nil'的用法,通过实例代码展示了如何使用它来明确表示无值状态,并解释了其与NULL的相似之处及区别。
2652

被折叠的 条评论
为什么被折叠?



