home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!ames!saimiri.primate.wisc.edu!zaphod.mps.ohio-state.edu!rphroy!einstein!wenner
- From: wenner@einstein.eds.com (Rich Wenner)
- Newsgroups: comp.lang.c
- Subject: Re: Hows this for odd
- Message-ID: <1266@pascal.einstein.eds.com>
- Date: 10 Nov 92 22:38:38 GMT
- References: <1992Nov9.102217.23060@monu6.cc.monash.edu.au> <1992Nov9.231340.10201@ptcburp.ptcbu.oz.au> <1992Nov10.161008.27590@mksol.dseg.ti.com>
- Organization: Electronic Data Systems
- Lines: 50
-
- In article <1992Nov10.161008.27590@mksol.dseg.ti.com> mccall@mksol.dseg.ti.com (fred j mccall 575-3539) writes:
- >In <1992Nov9.231340.10201@ptcburp.ptcbu.oz.au> michi@ptcburp.ptcbu.oz.au (Michael Henning) writes:
-
- >>bena@yoyo.cc.monash.edu.au (Ben Aveling) writes:
-
- >>>Just recently I saw the following fragment of code, and I thought I'd share
- >>>it with you all. (This is real code, part of a real program people will
- >>>pay money for.)
-
- >>> ... ,(i==0)?TRUE:FALSE,...
-
- >>From the source code for a popular UNIX debugger:
-
- >> if (strncmp(p, "", 1) != 0) {
- >> ...
- >> }
-
- >>There are lots of gems like that around :-(
-
- >Well, I generally do the explicit comparison on string comparisons,
- >too, because ...
-
- I think you missed the point. The above code compares "p" and the null string
- for a span of either 1 character or 1 more than the length of the shorter
- string, whichever is less. This is something a sane programmer would code
-
- if (*p)
-
- or, for the more verbose (but still sane -- no flames, please),
-
- if (*p != '\0')
-
- >I'm afraid I find this other idiom ("(i==0)?TRUE:FALSE") to be just a
- >bit peculiar, though.
-
- Just a bit peculiar? My, but you are a kind-hearted soul. :)
-
- Why is it that nobody in this thread has yet mentioned that the above
- expression reverses the logic? Is this equivalent to
-
- !i
-
- or have I been reading too much of my students' code?
-
-
- --
- Rich Wenner | Subject and verb always has to agree.
- wenner@csid.gmeds.com | Consult a dictionary frequently to avoid mispelling.
- | Hopefully, you will use words correctly,
- #include <stddisclaim.h> | irregardless of how others use them.
-