For vs while (was Re: Comparing strings...)
Sean Fagan
seanf at sco.COM
Sat Oct 20 19:18:39 AEST 1990
In article <2226 at ukc> tlg at ukc.ac.uk (T.L.Goodwin) writes:
>Almost, but not quite. If the body of the loop contains a "continue",
>then the second example becomes an infinite loop (other changes to i
>and "break"s notwithstanding), since the increment is never reached.
#define while(cond) for(;cond;)
(I'm sitting here trying to think of any case where this will break
[no pun intended 8-)] something; I can't think of any, offhand.)
If you have something such as
while () {
whatever;
}
this will be an infinite loop given the macro, but a syntax error otherwise.
But that's all I can think of...
(I've wondered why C had while, because of this. The only think I could
think of was that for came after while, and They didn't want to break
existing code... Any commentators? [Henry? Chris? Doug? Dennis?])
--
-----------------+
Sean Eric Fagan | "*Never* knock on Death's door: ring the bell and
seanf at sco.COM | run away! Death hates that!"
uunet!sco!seanf | -- Dr. Mike Stratford (Matt Frewer, "Doctor, Doctor")
(408) 458-1422 | Any opinions expressed are my own, not my employers'.
More information about the Comp.lang.c
mailing list