本文介绍了null和NULL:有什么区别吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

null和NULL之间有什么区别。是x == null和x ==

NULL是一样的吗?编译器是gcc 3.2。


谢谢。

Hello,
What is the difference between null and NULL. Are x == null and x ==
NULL the same? The compiler is gcc 3.2.

Thanks.

推荐答案



NULL被你的实现定义为空指针常量。

null不需要定义标准在一个实现中。


见clc-faq第5节


问候


Irrwahn

-

伟大的思想在大圈子里奔跑。


NULL is defined as a null pointer constant by your implementation.
null isn''t required by the standard to be defined in an implementation.

See c.l.c-faq section 5
http://www.eskimo.com/~scs/C-faq/top.html
Regards

Irrwahn
--
Great minds run in great circles.




NULL被你的实现定义为空指针常量。

null不需要定义标准在一个实现中。


见clc-faq第5节


问候


Irrwahn

-

伟大的思想在大圈子里奔跑。


NULL is defined as a null pointer constant by your implementation.
null isn''t required by the standard to be defined in an implementation.

See c.l.c-faq section 5
http://www.eskimo.com/~scs/C-faq/top.html
Regards

Irrwahn
--
Great minds run in great circles.





C语言有NULL但没有null。写作时我使用NULL来表示在< stdlib.h>中定义的宏。并在讨论指针时。我讨论null字符时
使用null。通过null字符我是

指的是''\'''。


如果你要求区别的那么语义

介于(x ==''\''')和(x == NULL)之间,它取决于x是什么。关闭

顶部,他们将评估所有x的相同结果。我,

亲自使用(x ==''\''')如果x是char或int而且(x == NULL)如果x是

a指针。对于其他一切,您必须考虑

比较是否有效以及如何转换或推广。


-

darrell at cs dot toronto dot edu



main(){int j = 1234; char t [] =":@ abcdefghijklmnopqrstuvwxyz.\ n",* i =

" iqgbgxmdbjlgdv.lksrqek.n" ;; char * strchr(const char *,int); while(

* i){j + = strchr(t,* i ++) - t; j%= sizeof t-1; putchar(t [j]);} return 0;}



C language has a NULL but there is no null. When writing I use NULL to
indicate the macro defined in <stdlib.h> and when discussing pointers. I
use null when discussing the null character. By null character I am
referring to ''\0''.

With that semantics out of the way, if you are asking for the difference
between (x == ''\0'') and (x == NULL) it would depend on what x is. Off the
top of my head, they will evaluate to the same result for all x. I,
personally, use (x == ''\0'') if x is a char or int and (x == NULL) if x is
a pointer. For everything else you''d have to consider whether the
comparison is valid and how things will be converted or promoted.

--
darrell at cs dot toronto dot edu
or
main(){int j=1234;char t[]=":@abcdefghijklmnopqrstuvwxyz.\n",*i=
"iqgbgxmdbjlgdv.lksrqek.n";char *strchr(const char *,int);while(
*i){j+=strchr(t,*i++)-t;j%=sizeof t-1;putchar(t[j]);} return 0;}


这篇关于null和NULL:有什么区别吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 23:40