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