Article View: comp.lang.c.moderated
Article #2261Re: use of the break statement
From: Miguel Carrasquer Vidal
Date: Wed, 13 Mar 1996 12:39
Date: Wed, 13 Mar 1996 12:39
44 lines
1662 bytes
1662 bytes
bjj@sequent.com (Ben Jackson) wrote:
>In article <4h4dp2$8ml@solutions.solon.com>,
> <news@chaos.kulnet.kuleuven.ac.be> wrote:
>>
>>I like to code loops in the following way:
>>
>> for (;;)
>> {
>> if (condition)
>> {
>> // do something
>> }
>> else break;
>> }
>That is exactly:
> while (condition)
> {
> // do something
> }
>(Not that I'd arrange braces like that or use C++ comments in my C code)
>Your example includes a statement before the "if", so it doesn't translate
>as easily. However, the idiom for processing all the lines of a file with
>fgets would be:
> while (fgets(...)) {
> // do something
> }
I see you have kept the C++ comment [OK, it's a quotation], but you
still have changed the brace style to K&R. Well, my fingers would
have done the same: it's harder to switch off compliance to the One
True Brace Style than to the ANSI/ISO Standard...
==
Miguel Carrasquer Vidal ~ ~
Amsterdam _____________ ~ ~
mcv@pi.net |_____________|||
========================== Ce .sig n'est pas une .cig
Technical Details
Message-ID:
<4i6fmg$ov3@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailReferences:
<4h4dp2$8ml@solutions.solon.com> <4hvvm2$ops@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail From: mcv@pi.net (Miguel Carrasquer Vidal) Newsgroups: comp.lang.c.moderated Subject: Re: use of the break statement Date: 13 Mar 1996 06:39:44 -0600 Organization: Planet Internet Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4i6fmg$ov3@solutions.solon.com> References: <4h4dp2$8ml@solutions.solon.com> <4hvvm2$ops@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com X-Newsreader: Forte Free Agent 1.0.82