home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!math.fu-berlin.de!hamel!rene
- From: rene@hamel.uucp (Rene Mueller)
- Subject: Re: The Correct Way To Write C if-Statements
- Message-ID: <GI78YWO@math.fu-berlin.de>
- Sender: rene@hamel (Rene Mueller)
- Organization: Free University of Berlin, Germany
- References: <140742@lll-winken.LLNL.GOV> <1992Nov6.225622.25460@dg-rtp.dg.com> <hansg.721510062@risken> <1992Nov12.212728.8864@dg-rtp.dg.com> <hansg.722248402@risken>
- Date: Mon, 23 Nov 1992 22:27:02 GMT
- Lines: 28
-
- In article <hansg.722248402@risken>, hansg@risken.vd.volvo.se (Hans Granqvist) writes:
- |>
- |> But, I must object strongly to your
- |> saying that there's only need to test 'if' or 'if not'. Some FAQ I think
- |> once said (it still does, I presume) that there is a LOGICAL difference
- |> to 0, '\0', and NULL. So why not test against the correct values? After
- |> all, we are here to aid others understand our code when we are not
- |> around anymore... :-)
- First 0 and '\0' IS the same (char-values are treated as int inside computations).
- Next there is a slightly diffrence between NULL and NUL ('\0').
- NULL is defined as pointer!
- But inside if-statements it makes no difference!!
-
- |> |>And, then, is there the slight casuality that 'TRUE' was defined to, per
- |> |>chance, '4711'?
- |>
- Hmm..., very little chance...
- in most cases were both are defined it will looks this way:
- #define FALSE 0
- #define TRUE (!FALSE)
-
- |> |Anyone who defines TRUE and FALSE such that (! TRUE) isn't
- |> |equal to FALSE or (! FALSE) isn't equal to TRUE shouldn't be coding
- |> |in C. The only pair of values that meet both conditions is 0 for
- |> |FALSE and 1 for TRUE.
- TRUE
-
- rene@math.fu-berlin.de
-