Ryan Ply said:
I see in the errata these fun phrases. "the advice is debatable",
"possibly harmful", "can cover up an unintended error".
Lots of stuff that could, possibly, maybe happen.
And, in fact, has happened on quite a few occasions.
As for the "possibly
harmful for malloc" comment, its if malloc fails to be declared as
returning void *. Is there an place where it isn't?
Yes said:
I suppose my point
is that I don't understand why I should program for things that have a
firm chance of a definite maybe of happening.
Wait a moment. Whilst there are certainly very, very good reasons why you
*should* program for things that have a firm chance of a definite maybe of
happening, let's just look at the effort involved here in the two
techniques:
Technique 1 (your way) requires you to include the <stdlib.h> header and
requires you to type a pointer cast and requires you to fix the cast if the
type changes.
Technique 2 (which is what we like to call "the right way") requires you to
include the header.
So we're suggesting that you might like to do less work and get a better,
more maintainable program as a result. But hey, no pressure - if you want
to keep doing it in some way other than the right way, that's up to you - I
mean, some people just love to type, right?