"for" loops
Doug Gwyn
gwyn at smoke.BRL.MIL
Sat Jan 28 13:36:15 AEST 1989
In article <1611 at csuna.UUCP> abcscagz at 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.
More information about the Comp.lang.c
mailing list