📄 nullvs0.rs.html
字号:
<html><!-- Mirrored from c-faq.com/null/nullvs0.rs.html by HTTrack Website Copier/3.x [XR&CO'2008], Sat, 14 Mar 2009 07:59:50 GMT --><head><title></title></head><body>From: Richard Stamp<br>Newsgroups: comp.lang.c<br>Subject: Re: NULL vs Int 0<br>Date: Sun, 7 Feb 1999 16:57:20 -0000<br>Message-ID: <918407071.27444.1.nnrp-12.9e98ce80@news.demon.co.uk><br>References: <79fckc$jc2$1@news1.mts.net> <79fdke$1r8$1@remarQ.com> <79ijbq$njb$1@nnrp1.dejanews.com> <36BD1771.7835@infi.net> <918393784snz@genesis.demon.co.uk><p>Lawrence Kirby wrote in message <918393784snz@genesis.demon.co.uk>...>Null pointers work perfectly well on platforms where "address 0" can<br>>point to a valid object. However there is a reason for why a null pointer<br>>should <em>compare</em> equal to zero and that is that tests like <TT>if ()</TT><br>>statements do the natural thing. Given that it makes sense for null<br>>pointer constants to be defined in a consistent way.<p>The reason people find this confusing (and it's clear that lots of people<em>do</em> find it confusing; I remember being very confused myself a while ago)is, I think, that 0 changes in meaning depending on the situation in whichit's used.<p>Normally 0 means integer zero, but in some cases it means null pointer.It's natural to try to find a link between these and think of the nullpointer as pointing to address 0, but as the FAQ makes clear this isn't avalid approach.<p>We're all familiar with operators changing their meaning according tocontext (the - operator behaving quite differently with pointers than withnumbers, for example), but it's more surprising to see a constant actingthat way.<p>Cheers,<br>Richard</body><!-- Mirrored from c-faq.com/null/nullvs0.rs.html by HTTrack Website Copier/3.x [XR&CO'2008], Sat, 14 Mar 2009 07:59:50 GMT --></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -