Thursday, September 11, 2014

Errata for: Sams Teach Yourself C Programming in One Hour a Day, Seventh Edition

     I'm currently reading Sams Teach Yourself C Programming.  Although not new to C, I like to relearn and read works on C programming.  In this post I thought it would be good to keep my own errata page on this book as it seems the website for tracking errata from the publisher is not yet updated.

     Check back often as I go through the book I will update the errata here.  If you have any errata yourself, please let me know and I will add it.
Thanks.

pg. 15 Step 8:
Although not errata per se, it is rather Windows centric.
If you are on OSX you will not see hello.obj or hello.exe but rather a.out
(or if you used gcc hello.c -o hello hello.c you will see hello.out).
To run hello.out (or a.out) type ./hello.out (or ./a.out) depending.
(I can't speak for Linux OS).

pg. 35 Exercise 5:
line 9 shows  fgets(buffer);  Your compiler should complain it needs 3 arguments.
line 9 should be  fgets ( buffer , 256 stdin );

pg. 44 Table 3.3:
"Full Name" and "Commonly Used Keyword" labels are switched.

pg 60 Do/Don't list:  Under Don't - second Don't 'forward slash' should be 'backslash'.
  Don't forget to use a backslash to continue a string of characters onto a second line.

pg 89 Exercise 3: Says to make listing 4.1 count up instead of down, but listing 4.1 already does that.

pg 112 Last Sentence under Recursion: "the factorial of 9 and larger values are outside the allowed
  range of integers."  This depends on your compiler.  Xcode for mac for instance
  lists an unsigned integer to be 4 bytes and can handle a factorial up to 12! .

pg 238 Question 10b.  answer is shown as 'A' but 10e. is shown as 73.  If by values they mean
  the integer then 10b. (*string) then should be 65 not 'A' or if by value they mean char, then
  10e should be ' I '.  Inconsistent.

pg 242 Defining and Declaring.  This author mixes and mostly inverts the definition of 'declaration'
  and 'definition' of the type struct.  As per 'The C Programming Language' by K&R, "The keyword
  struct introduces a structure declaration, which is a list of declarations enclosed in braces." Not until
  a struct is instantiated is the struct 'defined'.  When it is defined, then storage is created and set aside.

pg 257 Line 4 of program.  Should have a semi-colon after bracket.  };

pg 266 Line 17 of program should be:        17:    {4, "Benjamin"},

pg 366 Listing 15.2  %p's should be %lu's.    so:
    printf("\nThe size of multi = %p", sizeof(multi));     //should be:
    printf("\nThe size of multi = %lu", sizeof(multi));    //same for next two lines.

pg 367 5th paragraph: Says "In other words, it's incremented by the size of the object to which it
    points."  While not an error, it is an ambiguous idea with the previous page that shows 'multi' to be     of size 32.  So one would think multi + 1 should be pointing to something 32 bytes larger; but it
    does not. It points to something 16 bytes larger.

pg 367 Listing 15.3 (all printf's) uses format specifier %u and it should be %p for addresses.
    also, 'value' should be 'address' in lines 10 and 11.





2 comments:

James C said...

This is very useful! Thank you!

wlawhorn said...

Thanks so much for documenting these errors. Just got stuck on the one at page 35.