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. 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
Printed, PDF, ePub
Page 27
Table 2-3

-0 should be 0, there is no negative zero.

mostafa mahmoud ibrahim mohamed  Oct 10, 2017 
PDF
Page 367

bufGet() in buffer.c of example 14-4-5 only works for the first consumer.
Then it hangs because on consumer timeout the mutex is not unlocked.
Therefore cnd_timedwait cannot relock the mutex for the remaining consumers 2 and 3.

This works:

bool bufGet(Buffer *bufPtr, int *dataPtr, int sec) {
struct timespec ts;
timespec_get( &ts, TIME_UTC ); // The current time
ts.tv_sec += sec; // + sec seconds delay.
mtx_lock( &bufPtr->mtx );
while ( bufPtr->count == 0 ) {
int res = cnd_timedwait(&bufPtr->cndGet, &bufPtr->mtx, &ts);
if (res != thrd_success) {
mtx_unlock( &bufPtr->mtx ); // needed or other consumers will hang !
return false;
}
}
*dataPtr = bufPtr->data[bufPtr->tail];
bufPtr->tail = (bufPtr->tail + 1) % bufPtr->size;
--bufPtr->count;
mtx_unlock( &bufPtr->mtx );
cnd_signal( &bufPtr->cndPut );
thrd_yield();
return true;
}

Note from the Author or Editor:
The example works because a consumer thread is destroyed when bufGet() returns false.
But, of course, bufGet() should unlock the mutex. So replace the line

return false;

with

{ mtx_unlock( &bufPtr->mtx ); return false; }

Gerhard  Oct 01, 2017 
PDF
Page 708
9th

The single-character variable $^ is printed with a subscript ^ symbol.

Elias Rodrigues  Jul 06, 2017 
Printed, PDF
Page 33
2nd paragraph

It looks like it is missing a space between the words "macro" and `__STD_NO_COMPLEX__`

Elias Rodrigues  Jun 20, 2017 
Printed, PDF
Page 505
last 2 paragraph

"the function
sets the shift state stored at the address static to the initial shift state."

here the "static" should be "state".

meebox  Jul 29, 2016 
Printed
Page 213
5th line up from bottom

Change "fopen()" to "freopen()".

(Thanks to Igor V. Krasikov.)

Tony Crawford
 
May 11, 2016 
Printed
Page 152
2nd line up from bottom

Change "*((*arrPtr)+1)" to "*((*arrPtr)+i)".


(Thanks to Igor V. Krasikov.)

Tony Crawford
 
May 11, 2016 
Printed
Page 36
Fifth line up from bottom

Change "positive integer powers of 2" to "non-negative integer powers of 2".

(Thanks to Igor V. Krasikov.)

Tony Crawford
 
May 11, 2016 
Printed
Page 385
The subhead line of the section "casinh"

Change "Calculates the inverse hyperbolic sine of a number."
to "Calculates the inverse hyperbolic sine of a complex number."

(Thanks to Toshiaki Kurokawa.)

Tony Crawford
 
Apr 28, 2016 
Printed
Page 310
Line 11 from bottom

The indented line

The following macros are defined for the types intmax_tand uintmax_t:

should not be indented, because the line does not belong to the preceding bullet.

(Thanks to Toshiaki Kurokawa.)

Tony Crawford
 
Apr 28, 2016 
Printed
Page 305
Lines 10-13 from top

The paragraph
For a description of these enumeration constants with examples, see “Memory
Ordering”on page 249. An argument of the type memory_orderis used with the
atomic functions whose names end with the suffix _explicit, such as
atomic_store_explicit(), and with the function atomic_thread_fence().
should be indented so that the description belongs to the bullet “memory_order.”

(Thanks to Toshiaki Kurokawa.)

Tony Crawford
 
Apr 28, 2016 
Printed
Page 292
line 3 from top

Change 'See also "Mathematical Functions" on page 323' to 'See also "The Floating-Point Environment" on page 327'.

(Thanks to Toshiaki Kurokawa.)

Tony Crawford
 
Apr 28, 2016