T
TTroy
I FOUND MAJOR ERRORS in K&R2 (making it almost useless for the herein
mentioned topics).
K&R2 Section 5.9 Pointers vs. Multidimension Arrays starts of like
this...
"Newcomers to C are somtimes confused about the difference between a
two-dimensional array and an array of pointers..."
then continues to explain int *b[10]; to be...
"For b, however, the definition only allocates 10 pointers ... Assuming
that each element of b does point to a twenty element array,then there
will be 200 ints set aside, plus ten cells for pointers... "
Is it just me, or is that explanation only valid for int (*b)[10];
????
I'm pretty sure K&R2 is totally wrong in this section (had me confused
for a while).
Later on in section 5.9, it says "... by far the most frequent use of
arrays of pointers is to store character strings of diverse lengths..."
Once again, this seems totally wrong.
char *strings[] = {"Bob","Dave","Jack");
'strings' is only managing pointers to anonymous objects that are
automatically created by the initialization (which there is no mention
of in this section). 'strings' doesn't strore "Bob" "Dave" "Jack".
All in all, K&R2 has been an amazing book, but this one section (which
is often the hardest for beginners) makes it a less amazing book
(rather average).
Am I right here, or am I wrong (I'm pretty sure I'm right, but I still
don't know how these mistakes could be in the book, considering the
authors and the many decades it has been the bible).
How come these errors weren't caught? How come none of the errata I
have found mentions these? Am I totally wrong?
mentioned topics).
K&R2 Section 5.9 Pointers vs. Multidimension Arrays starts of like
this...
"Newcomers to C are somtimes confused about the difference between a
two-dimensional array and an array of pointers..."
then continues to explain int *b[10]; to be...
"For b, however, the definition only allocates 10 pointers ... Assuming
that each element of b does point to a twenty element array,then there
will be 200 ints set aside, plus ten cells for pointers... "
Is it just me, or is that explanation only valid for int (*b)[10];
????
I'm pretty sure K&R2 is totally wrong in this section (had me confused
for a while).
Later on in section 5.9, it says "... by far the most frequent use of
arrays of pointers is to store character strings of diverse lengths..."
Once again, this seems totally wrong.
char *strings[] = {"Bob","Dave","Jack");
'strings' is only managing pointers to anonymous objects that are
automatically created by the initialization (which there is no mention
of in this section). 'strings' doesn't strore "Bob" "Dave" "Jack".
All in all, K&R2 has been an amazing book, but this one section (which
is often the hardest for beginners) makes it a less amazing book
(rather average).
Am I right here, or am I wrong (I'm pretty sure I'm right, but I still
don't know how these mistakes could be in the book, considering the
authors and the many decades it has been the bible).
How come these errors weren't caught? How come none of the errata I
have found mentions these? Am I totally wrong?