Errata

C in a Nutshell

Errata for C in a Nutshell, Second Edition

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.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Printed Page ii
Revision History for the Second Edition

The date of the Second Release is prior to the date of the First Release.

Steven Huggins  Dec 02, 2024 
PDF Page 8
3rd line of the 1st multi-line example

Semicolon is missing at the end of this line ("area = pi * r * r")

Vadim Flyagin  Jul 23, 2024 
Printed Page 8
3rd line of the 2nd multi-line example

Semicolon is missing at the end of this line ("area = pi * r * r")

Vadim Flyagin  Jul 23, 2024 
Printed Page 9
line 13

On line 13, the 29 graphic characters are displayed. They each have a space in between, except for the pair parentheses. So it would be nice to replace () by ( )
in other words, to put a space between the parentheses, for consistency with the way that the other characters on the line are displayed, with a space in between.

Mark Daniel Ward  Mar 24, 2022 
Printed Page 10
displayed code in the section on wide characters

The line:
wchar_t wc = '\x3b1';
seems to be missing an L
It should read:
wchar_t wc = L'\x3b1';

For comparison, the corresponding line page 11 is correct, but on page 10, the L is missing.

Mark Daniel Ward  Mar 25, 2022 
PDF Page 18
Last paragraph, first line.

Change "delcared" with "declared"

Fedon Kadifeli  Jan 19, 2021 
Printed Page 104
Example 6.3

The variable `command` should be declared outside of the block in order to be avaiable to the loop controlling condition.

Original Example:
```
do {
int command = ...
} while (command != END);
```

Suggested Example:
```
int command;
do {
command = ...
} while (command != END);
```

Daniel Augusto  May 18, 2024 
Printed Page 116
Example 7-3

Example 7-3 uses the long double type "in order to accommodate very large results" of the factorial function. According to the book (page 31), the long double format corresponds to the 80 bits extended precision, whose fractional part uses 64 bits. That means that the long double format can represent all integers only up to 2^64. After that, more and more integers are not representable. As a consequence, some results will be rounded (e.g., starting from n=26, factorial(n) as returned by the program in Example 7-3 is wrong).

Using the C99 standard mandated uint_least64_t format, all factorials up to 20 can be computed. The extra range offered by the long double format (correct results up to 25 only) is certainly not worth the trouble and should be strongly discouraged here.

Frederic Goualard  Jan 15, 2020 
Printed Page 135
Code snippet at bottom.

The length of the string L"chop suey" is 9, not 10.
Consequently, the array length is 10, and the array size is 10 * sizeof(wchar_t).

Steven Huggins  Nov 30, 2024 
Printed Page 142
Line 19

A space is missing in "pointeriPtr".

Steven Huggins  Dec 02, 2024 
Printed Page 254
8 lines from the bottom of the source listing

Errata in the errata. The issue reported with bufGet not unlocking a mutex says it's on page 367. The listing (Example 14-4) is actually on page 254.

Also, bufPut should unlock the mutex before returning false as well.

Nathan Youngman  Sep 04, 2019 
PDF Page 316
Fifth enumeration constant from top of page

The enumeration constant "thrd_timeout" should read: "thrd_timedout"

Fedon Kadifeli  Feb 25, 2021 
PDF Page 316
Middle of page

"mtx_plain" in "mtx_plain|mtx_recursive" (0|1) has no effect and should be replaced with "mtx_recursive" only

Fedon Kadifeli  Feb 25, 2021 
PDF Page 670
1st para

Pretty sure "thread.h" should be "threads.h"

Robert P. J. Day  Jul 23, 2019 
PDF Page 697
3rd line from top

$(LDFLAGS) should be put at the end of the command, so that the command reads like this:

$(CC) -o $@ $^ $(LDFLAGS)

Similarly the last line on the same page should be updated like this:

gcc -o circle circle.o circulararea.o -lm

This is necessary for the linker to use the libm.a library; otherwise you will get linker errors like "undefined reference to ..." for functions used from this library.

Fedon Kadifeli  May 05, 2021 
PDF Page 741
first line

the environment variable should be HOME_PATH, not HOME.

meebox  Jul 08, 2016