* Floare Augustin Theodor:
That is an exaggeration. I've looked at the indicated page and I can
tell that for:
------------------------------
"Page 19
In general, negative numbers are represented using the two's
complement approach...
This is not a C feature. It is a common implementation, but it is
specifically not required. (Binary is, but one's complement is not
unheard of.)"
------------------------------
"In general, negative numbers are represented using the two's
complement approach... " That is true, but the author does not say
that it is or it is not a C feature. Following this logic, we can say,
there are a lot of words in his book that are not C keywords!
It's difficult to say anything about a quote taken out of context, but on its
own Schildt is correct here, it's true that most C and C++ implementations,
almost all of them, use two's complement form for signed integer types, although
Schildt's use of weasel words ("in general"), overspecificity ("negative") and
needless generalization ("numbers") means that it's possible to interpret it
adversarially as incorrect.
and
------------------------------
"Page 53
printf("%f", sizeof f);
printf("%d", sizeof(int));
Clearly wrong; sizeof is not a double or float. It is also not an
int; it is an unsigned integral type, thus, one of unsigned char,
unsigned short, unsigned int, or unsigned long.
The only safe way to do this is:
printf("%lu", (unsigned long) sizeof(int));
While this is larger, a clear explanation of why it is required
will go a long way towards helping people understand C."
------------------------------
Here, the argument does not fit because sizeof is an unary compile-
time operator. The proof:
int s = sizeof(int);
is translated into
mov DWORD PTR _s$[ebp], 4
Therefore, sizeof(int) is replaced with an integer number and that
number can be printed as an integer or as a float.
Schildt's first printf is incorrect, just Undefined Behavior.
So, of the two alleged critcism errors you've quoted from the Schildt bashing
page, 1 is not an error and 1 is an error.
I write "bashing" page because it's so unnecessary to drop down to the same
level of inaccuracy as that one is criticizing (whoever made that page).
<q>
Page 33
The following heading occurs:
"static Global Variables"
No such thing. A static variable outside of a function has file scope, which is
distinct from global scope.
</q>
This is just verbiage, an adversarial interpretation: the word "global" has a
language-independent common meaning (the opposite of "local") where Schildt's
heading is meaningful. Anyway it's silly to attack a book on a difference over
what a word "should" mean, or by imposing a clearly unintended context. If the
author implicitly or explicitly defines the word (I don't know if Schildt does)
then all's fine, regardless of whether someone disagrees about ideal usage.
<q>
Page 53
The following code:
"
/* Write 6 integers to a disk file. */
void put_rec(int rec[6], FILE *fp)
{
int len;
len = fwrite(rec, sizeof rec, 1, fp);
if (len != 1) printf("write error");
}
"
Is described as causing all of rec to be written, no matter what size of array
is being used.
Incorrect.
</q>
This is true, Schildt's code is completely nuts.
<q>
Page 59
"This shorthand works for all the binary operators... "
No, it doesn't. It doesn't work for ".", "->", "&&", or "||". For that matter,
it doesn't work for the function call operator or the array operator, both of
which are, roughly, binary operators.
</q>
The "No, it doesn't" is a correct criticism. The commentary about function call
operator and array operator is nonsense.
<q>
Page 63
If scanf fails, the variable guess is referenced before it has been initialized;
accessing an uninitialized object introduces undefined behavior.
</q>
Since no quote from the Schildt book is provided for this criticism, it's
impossible for me to say whether the criticism here is correct, but it seems
likely that it is correct (i.e. that Schildt has a bug in his code).
After this follows about 15 more critcisms which (assuming the Schildt quotes
are correct) *are* correct, where it's demonstrated that Schildt lacks
fundamental knowledge and insight about the matters he writes about.
So, out of about 20-21 criticisms (I'm too lazy to count), about 2 are incorrect
adversarial interpretation criticisms, 1 is half correct half nonsense, and the
rest of the critcisms seem to be correct.
Which, considering how basic the stuff is that Schildt discusses and get
completely wrong, means that the bashing page's title, "C: The Complete
Nonsense", is probably not at all misleading.
Cheers & hth.,
- Alf
CC: The bashing page author (since there was a mail-address at the bottom).