|
|
On Apr 2, 12:26 pm, aark...@xxxxxxxxx wrote:
> Hi all,
>
> I was going through the book "C Elements of style" by steve oualline.
> in this book many guidelines are given.
>
> the following were seen in the book as rules
>
> 1) while(1) is preferred over for(;;)
I am opposite here. The constructs create identical results and the
meaning for both is obvious. Some lints and compilers will whine
about while (1) but they do not add any noise for for(;;).
> 2) use of const is preferred over #define
This one is obvious. #define can unexpectedly change something if you
are not careful.
> 3) unless extreme efficiency is warranted, use printf instead of putc
> & puts
Nonsense. If there is no format string, use puts(). If you are
outputting a single character, use putc().
> now my question is
>
> can anyone give examples for the justification of above rules ..????
>
> OR
> To what extent these rules are true..???
I like number 2, and the other two rub me the wrong way.
|
|