Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!sharkey!mcf!mibte!gamma!thumper!ulysses!andante!alice!ark From: ark@alice.UUCP (Andrew Koenig) Newsgroups: comp.lang.c Subject: Re: use of if (!cptr) and if (cptr), where cptr is a * Keywords: * != int Message-ID: <9626@alice.UUCP> Date: 17 Jul 89 18:55:36 GMT References: <10099@mpx2.mpx.com> Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 26 In article <10099@mpx2.mpx.com>, erik@mpx2.mpx.com (Erik Murrey) writes: > char *cptr, *malloc(); /* ok, so maybe malloc is void * by now... */ > x() > { > cptr= malloc(...); > if (!cptr) > fatal("cannot malloc"); > ... > } No problem. The folowing expressions are all equivalent in this context: !cptr cptr==0 cptr==NULL cptr==(char *)0 cptr==(char *)NULL Which one you use is a matter of personal taste and style. -- --Andrew Koenig ark@europa.att.com