use of if (!cptr) and if (cptr), where cptr is a *
Andrew Koenig
ark at alice.UUCP
Tue Jul 18 04:55:36 AEST 1989
In article <10099 at mpx2.mpx.com>, erik at 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 at europa.att.com
More information about the Comp.lang.c
mailing list