Path: csiph.com!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Loops (was Re: do { quit; } else { }) Date: Wed, 16 Apr 2025 13:18:29 -0700 Organization: None to speak of Lines: 23 Message-ID: <874iyn273e.fsf@nosuchdomain.example.com> References: <20250413072027.219@kylheku.com> <20250415053852.166@kylheku.com> MIME-Version: 1.0 Content-Type: text/plain Injection-Date: Wed, 16 Apr 2025 22:18:30 +0200 (CEST) Injection-Info: dont-email.me; posting-host="d66e934c2e3cca42eaa548516797f624"; logging-data="3083081"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+6vFNimL5MnV0BsZkpngBf" User-Agent: Gnus/5.13 (Gnus v5.13) Cancel-Lock: sha1:GdZ3vJPFo81ET2mKL94uSIV0fGw= sha1:OfaXWBk84pyDXroiom+lQ0vC1GM= Xref: csiph.com comp.lang.c:392628 scott@slp53.sl.home (Scott Lurndal) writes: > bart writes: >>On 16/04/2025 15:09, Scott Lurndal wrote: [...] >>> for(i = 1; i++ <= 10;) >> >>So real for loops are a /two-way/ construct? >> >>In any case, that doesn't do the same as the others, as it iterates over >>2 to 11 inclusive, not 1 to 10. > > The point was to execute a loop 10 times, which this does. You didn't say that was the point. A very common requirement is to have a meaningful value for i inside the loop. `for (i = 1; i <= 10;i ++)` does that, and is far more idiomatic. Your example does demonstrate the flexibility of a C-style for loop, but it's not good code. -- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com void Void(void) { Void(); } /* The recursive call of the void */