ro****@pc18.math.umbc.edu (Rouben Rostamian) wrote:
I suggest that you don't read "C For Dummies". It has the potential
to mislead you.
I am basing this statement based on the author's VERY confused
rambling in:
http://www.c-for-dummies.com/lessons.../01/index.html
He shows a program that compiles and runs under Windows but
crashes under Linux. He appears to puzzled why this happens.
His problem is that he is trying to modify a string literal.
Wow. I had not realised quite how terrible this book was, until
I read the other 'lessons':
http://www.c-for-dummies.com/lessons/
The author appears to have learned C by trial-and-error, and not
consulted with any experienced C programmers.
The real clincher for me is "Bonus Lesson 2". He presents a "clever"
trick to obtain a string representation of a float: write the float
to a file with fprintf, and then read it back in with fgets.
He goes on to explain that "nobody writes in ANSI C because you have
to do things like this". (Apparently he hadn't heard of sprintf).
Also defying belief is Bonus Lesson 1, which contains:
#include <stdio.h>
#define NULL 0
Finally, a good example of the book's style can be seen in Bonus Lesson
13.2 (which was snipped from the published edition, thankfully):
#include <stdio.h>
#include <stdlib.h>
void main()
{
char value[8];
int v;
printf("Enter a value, 0 to 32000:");
gets(value);
v = atoi(value);
printf("Decimal value is %i\n",v);
printf("Hexadecimal value is %4X\n",v);
}