how has C bitten you?

der Mouse mouse at mcgill-vision.UUCP
Fri Aug 23 18:34:51 AEST 1985


  [ ... ]
>	if(telno){		/*  should be if(*telno)  */
  [ ... ]

> Print statements showed the telno was being handed to the routine,
> but the if said nothing was there.  Turns out, on my system, the
> address of telno is NULL.  I needed to check the contents not the
> address!

Gee....and I thought a zero pointer was guaranteed not to point to
anything valid (K&R says this).  Or is NULL not a zero?!  No, you
are comparing to 0 not NULL.
-- 
					der Mouse

{ihnp4,decvax,akgua,etc}!utcsri!mcgill-vision!mouse
philabs!micomvax!musocs!mcgill-vision!mouse

Hacker: One responsible for destroying /
Wizard: One responsible for recovering it afterward



More information about the Comp.lang.c mailing list