:: Re: [DNG] Studying C as told. (For …
Etusivu
Poista viesti
Vastaa
Lähettäjä: Peter Olson
Päiväys:  
Vastaanottaja: Edward Bartolo, KatolaZ
Kopio: dng
Aihe: Re: [DNG] Studying C as told. (For help)
> 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.

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.

Peter Olson