home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / c / 18317 < prev    next >
Encoding:
Internet Message Format  |  1992-12-14  |  1.0 KB

  1. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!rz.uni-karlsruhe.de!not-for-mail
  2. From: "hans friedrich steffani" <GM08@DKAUNI2.BITNET>
  3. Newsgroups: comp.lang.c
  4. Subject: a question about if and case
  5. Date: 14 Dec 1992 15:47:20 +0100
  6. Organization: University of Karlsruhe, Germany
  7. Lines: 41
  8. Sender: usenet@nz12.rz.uni-karlsruhe.de
  9. Distribution: world
  10. Message-ID: <1gi6poINN3lv@nz12.rz.uni-karlsruhe.de>
  11.  
  12.  
  13. i have something like
  14.  
  15. int i;
  16.  
  17. if( i == 1 || i == 25 || i == 125 )
  18.  {
  19.   /* do something sophisticated */
  20.  }
  21. if( i == 2 || i == 30 || i == 244 )
  22.  {
  23.   /* do something different */
  24.  }
  25.  
  26. or should i use
  27.  
  28. switch( i )
  29.  {
  30.   case 1:
  31.   case 25:
  32.   case 125:
  33.   /* do something sophisticated */
  34.   break;
  35.  
  36.   case 2:
  37.   case 30
  38.   case 244:
  39.   /* do something different */
  40.   break;
  41.  
  42.   default:
  43.   break
  44.  }
  45.  
  46. or is there a third way??
  47. i need contructions like this very often so i need a GOOD
  48. solution.
  49.  
  50. hans friedrich   steffani@imbaibrs1.bau-verm.uni-karlsruhe
  51. steffani         gm08@rz.uni-karlsruhe.de
  52.                  gm08@dkauni2.bitnet
  53.