:: Re: [DNG] Studying C as told. (For …
Góra strony
Delete this message
Reply to this message
Autor: Hendrik Boom
Data:  
Dla: dng
Temat: Re: [DNG] Studying C as told. (For help)
On Thu, Jun 23, 2016 at 11:34:23PM -0400, Peter Olson wrote:
> > On June 23, 2016 at 10:48 AM Edward Bartolo <edbarx@???> wrote:
> >   if (count > 0)
> >     while(putchar(' ') && --count);

>
> I strongly recommend using the continue statement here:
>
>       while(putchar(' ') && --count) continue;

>
> The reason is that the semicolon by itself is almost unnoticeable
> and you can create a difficult to understand malfunction if you don't
> notice you forgot to type it.


I learned C in the 70's. I still seem to have things to learn. And this
possibility has been there all that time.

Thank you.

-- hendrik

>
> Another habit I have is to avoid a statement like:
>
>     if (abc == 42)

>
> and write it as
>
>     if (42 == abc)

>
> instead. The compiler will issue an error message if you type only
> one = in the latter form, whereas the first form will happily execute
> by setting abc to 42 and always taking the true clause.


I had figured this one out.

-- hendrik