Sean Conner wrote:
It was thus said that the Great Don once stated:
Ethan Dicks wrote:
> The "real" problem was that the first guy didn't really understand the
> impact of his original construction on the underlying system, and "it
> worked" for a few thousand names. Didn't scale worth beans, though.
But really, it gets to me when I see code like:
for (i = 0 ; i < MAX ; i++)
foo[i] = 0;
when it could easily be replaced with:
memset(foo,0,sizeof(foo));
The problem here is when someone walks in and says, "Oh, I need
to init the array to '1's instead of '0's" and replaces that with:
memset(foo,1,sizeof(foo));
which chokes if sizeof(foo[0]) > 1
If this appears in a seldom invoked place, I prefer the more
explicit (i.e. former) code fragment. :-(
(which would work on multiple dimentioned arrays)
or, if C allowed it:
foo = 0;
(to me, if the compiled sees array rvalue being set to a single lvalue,
then the intent I want as a programmer is to set the entire array to that
single value).