Head First C

Errata for Head First C

Submit your own errata for this product.


The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.


Color Key: Serious Technical Mistake Minor Technical Mistake Language or formatting error Typo Question Note Update



Version Location Description Submitted By Date Submitted Date Corrected
Safari Books Online
32
The Polite Guide to Standards

The option to compile to the C99 standard is -std=c99 not -std=99.

Note from the Author or Editor:
In "The Polite Guide to Standards" change "-std=99" to "-std=c99"

Thomas Corbière  Aug 05, 2012 
PDF
Page 37
while condition of Exercise Solution

The first time through the while loop the condition "card_name[0] != 'X'" is reading uninitialized memory, it could find any value there including 'X' (terminating the program before any input is accepted).

Note from the Author or Editor:
The bug is in the exercise on page 35/37. The: while(card_name[0] != 'X') { ... printf("Current count: %i\n", count); } needs to be switched to a do/while loop: do { ... printf("Current count: %i\n", count); } while(card_name[0] != 'X');

Patrick Lahey  Jul 09, 2012 
Safari Books Online
67
sizeof(food) explanation

"(‘/0’ included)" should be change to "(‘\0’ included)".

Note from the Author or Editor:
In the annotation 1/3 of the way down the page change '/0' included to '\0' included

Thomas Corbière  Aug 06, 2012 
Safari Books Online
88
What's my purpose? solution

The solution to the exercise is missing.

Note from the Author or Editor:
The blue-lines of the solution have gone missing from this page. They are available in the print editions. They should be put back on the page.

Thomas Corbière  Aug 06, 2012 
Safari Books Online
93
Annotation of the fourth solution

It's true that the solution is incorrect but I think that the main reason is that the parameters is not those expected by scanf() so the string length problem is irrelevant. Did you intend to write scanf("%80s", search_for)?

Note from the Author or Editor:
Replace: scanf(search_for, 80, stdin) with scanf("%80s", search_for)

Thomas Corbière  Aug 07, 2012 
PDF
Page 94
Middle of page

The sample code for the jukebox application uses the "fgets" function to get the user's search string. However, fgets will add the newline (\n) character to the end of the string when the user presses the enter key to submit their search string. This newline character must be removed and replaced with the null character (\0) in order for it to actually match one of the song titles in the tracks[] array. Without replacing the newline character, the code as listed on this page does not work (however, the screenshot on the next page shows it functioning properly). An example fix can be used directly after the following line: fgets(search_for, 80, stdin); // FIX TO REPLACE NEWLINE CHARACTER if(search_for[strlen(search_for) - 1] == '\n') { search_for[strlen(search_for) - 1] = '\0'; }

Note from the Author or Editor:
In the code on pages 91/93/94, each time the fgets() function is called, add the following line of code after it: search_for[strlen(search_for) - 1] = '\0';

Matthew Wilson  Jun 27, 2012 
Safari Books Online
94
First annotation

"You still need to stdio.h" should be changed to "You still need stdio.h".

Thomas Corbière  Aug 07, 2012 
Safari Books Online
128
1st paragraph

"then chances are you going" should be changed to "then chances are you're going".

Thomas Corbière  Aug 07, 2012