home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 17064 < prev    next >
Encoding:
Text File  |  1992-11-23  |  1.6 KB  |  40 lines

  1. Newsgroups: comp.lang.c
  2. Path: sparky!uunet!math.fu-berlin.de!hamel!rene
  3. From: rene@hamel.uucp (Rene Mueller)
  4. Subject: Re: The Correct Way To Write C if-Statements
  5. Message-ID: <GI78YWO@math.fu-berlin.de>
  6. Sender: rene@hamel (Rene Mueller)
  7. Organization: Free University of Berlin, Germany
  8. 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>
  9. Date: Mon, 23 Nov 1992 22:27:02 GMT
  10. Lines: 28
  11.  
  12. In article <hansg.722248402@risken>, hansg@risken.vd.volvo.se (Hans Granqvist) writes:
  13. |>
  14. |> But, I must object strongly to your
  15. |> saying that there's only need to test 'if' or 'if not'. Some FAQ I think
  16. |> once said (it still does, I presume) that there is a LOGICAL difference
  17. |> to 0, '\0', and NULL. So why not test against the correct values? After
  18. |> all, we are here to aid others understand our code when we are not
  19. |> around anymore... :-)
  20. First 0 and '\0' IS the same (char-values are treated as int inside computations).
  21. Next there is a slightly diffrence between NULL and NUL ('\0').
  22. NULL is defined as pointer!
  23. But inside if-statements it makes no difference!!
  24.  
  25. |> |>And, then, is there the slight casuality that 'TRUE' was defined to, per
  26. |> |>chance, '4711'?
  27. |>
  28. Hmm..., very little chance...
  29. in most cases were both are defined it will looks this way:
  30. #define    FALSE    0
  31. #define    TRUE    (!FALSE)
  32.  
  33. |> |Anyone who defines TRUE and FALSE such that (! TRUE) isn't
  34. |> |equal to FALSE or (! FALSE) isn't equal to TRUE shouldn't be coding
  35. |> |in C.  The only pair of values that meet both conditions is 0 for
  36. |> |FALSE and 1 for TRUE.
  37. TRUE
  38.  
  39.     rene@math.fu-berlin.de
  40.