Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!unmvax!pprg.unm.edu!hc!lanl!cmcl2!adm!smoke!gwyn From: gwyn@smoke.BRL.MIL (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: "for" loops Message-ID: <9519@smoke.BRL.MIL> Date: 28 Jan 89 03:36:15 GMT References: <739@jupiter.iis.UUCP> <1611@csuna.UUCP> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 13 In article <1611@csuna.UUCP> abcscagz@csuna.csun.edu (Jeff Boeing) writes: >Actually, C's "for" can be duplicated EXACTLY by C's "do ... while" loops. Only in the sense that, given "if" and any looping construct, any of the other looping constructs can be simulated. But there is no obvious straightforward mapping of a general "for" onto "do...while". For one thing, a "for" need not execute the controlled statement at all whereas "do...while" always executes it at least once. The other thing to beware of is the behavior of "continue". Many programmers have been confused by trying to map "for" into "while" and not realizing that "continue" does different things in the two cases.