Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!udel!rochester!rit!tropix!ur-valhalla!uhura.cc.rochester.edu!sunybcs!boulder!ncar!mailrus!purdue!haven!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: use of if (!cptr) and if (cptr), where cptr is a * Message-ID: <10562@smoke.BRL.MIL> Date: 15 Aug 89 16:21:55 GMT References: <10099@mpx2.mpx.com> <93@microsoft.UUCP> <10100@mpx2.mpx.com> Reply-To: gwyn@brl.arpa (Doug Gwyn) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 18 In article <10100@mpx2.mpx.com> erik@mpx2.mpx.com (Erik Murrey) writes: >Now, what happens with: >if (cptr == 0) ? Does the compiler cast the cptr to an int, and loose >the descriptor? (And tell is that it is null?) We've already explained this, but here it is again: Just because you see "0" in the source code does not mean that it acts an integer constant. In this context it is taken as (technically, is converted to) a null pointer of the appropriate type. A null pointer need not have an all-0 bit representation, but "0" is still the way you write it in C source code. In effect, the apparent integer constant "0" is converted to a pointer in this context; the pointer is not converted to int. >How about: >if (!cptr) ? Completely equivalent to "if(cptr==0)".