home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 17012 < prev    next >
Encoding:
Internet Message Format  |  1992-11-22  |  1.0 KB

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!ames!sun-barr!cs.utexas.edu!rutgers!modus!systemy!oliver!ugo
  2. From: ugo@oliver.sublink.org (Ugo Cei)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: The Correct Way To Write C if-Statements
  5. Message-ID: <1992Nov21.133259.29914@oliver.sublink.org>
  6. Date: 21 Nov 92 13:32:59 GMT
  7. References: <1992Nov12.101654.21932@thunder.mcrcim.mcgill.edu> <1992Nov12.140710@gese.ge14.mdadv.gv.at> <3860@dozo.and.nl> <1992Nov16.175117.29633@dg-rtp.dg.com> <BxvIyA.Co2@sci.kun.nl>
  8. Organization: Oliver System - Pavia ITALY
  9. Lines: 18
  10.  
  11. I am surprised that nobody has yet suggested this style:
  12.  
  13.     (cond) && expression;
  14.  
  15. or    (cond) && (expression, 1); in case "expression" has void type.
  16.  
  17. e.g.:       (1 == 1) && puts("1 == 1");
  18. instead of  if (1 == 1) puts("1 == 1");
  19.  
  20. If you want to reverse the condition, change "&&" to "||".
  21.  
  22.                     Ugo
  23.  
  24. P.S.: should I put a smiley in ? BTW, this is a common Perl idiom.
  25.  
  26. -- 
  27. Ugo Cei --- Via Colombo 7 - 27100 Pavia - ITALY   |
  28.          -- Sublink:  ugo@oliver.sublink.org      | "Real programs dump core"
  29.