home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / c / 16062 < prev    next >
Encoding:
Internet Message Format  |  1992-11-07  |  1.4 KB

  1. Path: sparky!uunet!sdrc!thor!scjones
  2. From: scjones@thor.sdrc.com (Larry Jones)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: About feof, ferror and return values (Was: Re: changing the contents of a file)
  5. Message-ID: <2222@sdrc.COM>
  6. Date: 5 Nov 92 15:22:17 GMT
  7. References: <HPV.92Nov3095653@kelvin.uio.no> <1992Nov4.092918.8359@black.ox.ac.uk> <1992Nov5.094701.9411@u.washington.edu>
  8. Sender: news@sdrc.COM
  9. Lines: 23
  10.  
  11. In article <1992Nov5.094701.9411@u.washington.edu>, bketcham@stein.u.washington.edu (Benjamin Ketcham) writes:
  12. > What's the difference between an unconditional for loop and an unconditional
  13. > while loop?
  14.  
  15. Well, there really isn't any such thing as an unconditional while loop
  16. -- while loops always have a condition, although it can be a constant. 
  17. for loops, on the other hand, allow the condition to be completely
  18. omitted.  Infinite loops have traditionally been written in C as:
  19.  
  20.     for (;;) { ... }
  21.  
  22. but lately many people seem to prefer:
  23.  
  24.     while (1) { ... }
  25.  
  26. This is purely a style issue -- there is no good technical reason to
  27. prefer one over the other.  (Originally, C compilers did very little
  28. optimization and the first form actually generated better code.  I would
  29. be very surprised if this was true of any contemporary compilers.)
  30. ----
  31. Larry Jones, SDRC, 2000 Eastman Dr., Milford, OH  45150-2789  513-576-2070
  32. larry.jones@sdrc.com  or  ...uunet!sdrc!larry.jones
  33. He piqued my curiosity. -- Calvin
  34.