Is "C For Dummies" any good?

K

Keith Thompson

Emmanuel Delahaye said:
I still don't understand why book writers do continue to teach scanf()
before gets()... Kinda mystery to me...

You mean fgets() rather than gets(), right?
 
J

Jarno A Wuolijoki

Any float
will be converted to a double (with a cost in terms of code space and CPU
time) before being processed (computing, function parameter etc.).

Apparently either my gcc is broken or your statement generalizes a bit
too far..

user@host$ cat foo.c
#include <stdio.h>
#include <limits.h>
int main(void) {
printf("%i\n", (int)(sizeof(1.0f+2.0f)*CHAR_BIT));
return 0;
}
user@host$ gcc foo.c -o foo && ./foo
32
 
A

Arthur J. O'Dwyer

kal wrote on 27/07/04 :
[>Someone else wrote:]
[>>Someone else wrote:]
What do you suggest instead ? Change rates are far to be integer
expressions! ^^^^^^^^^

As long as we're correcting your English idioms... :)
"unlikely to be" or "far from" would be correct (but have different
meanings from each other).

Anyway, as far as I know (which isn't very far), exchange rates
are generally imprecise, like the price of gas (or petrol:) The
"exchange rate" would then be an average of several going rates,
or whatever your particular bank is charging at the moment. So
exact floating-point precision would not matter so much. But you
would presumably want to be able to do exact multiplications; if
your program claimed that 1.5 times a billion dollars was 1.4998
billion, you'd be in trouble.

My conclusion: you'd want a floating-point number to store the
actual exchange rate, but you'd need an exact type to do the
math --- either bignum, or round the rate to the nearest thousandth
of a dollar (as with U.S. gas prices ;) and do the math in fixed
point.

For a newbie programming assignment, I think all but the most
anal of us will agree that 'double' is fine. ;-)

-Arthur
 
D

Dave Vandervies

Euclid's books, I to XIII.

Only if you're wanting to get into math as well as computer programming.
A better recommendation for getting into computer programming is Knuth.


dave

--
Dave Vandervies (e-mail address removed)
If someone is unwilling to accept those requirements ... they may be
better off just leaving. \ --Richard Heathfield
Off you go, then. Don't forget your coat. \ roasts a troll in CLC
 
R

Richard Pennington

K. G. Suarez said:
Thank you, Bernhard. I will keep that in mind

My response is very (or at least somewhat) offtopic. I've been writing a
(compiler? compiler/compiler? language system?) in C/C++ for quite a
while. This is a personal project, not (yet, if ever) a commercial one.

Part of my plan has been to document the project externally (i.e. the
"user's manual") and internally ("how it works") as I go. Eventually,
I'm thinking of providing both documents, probably along with the
source, in book form.

Right now the program is lightyears ahead of the documentation. (The
program works, as far as I've gotten it, the documentation is woefully
inadequate.) (This is pretty much how life is in my real job as a
developer. ;-)

My question is this: Is there value in such a book? What I'm trying to
do is describe a large program (granted a somewhat esoteric one) in a
way that gives some kind of insight into the design decisions that went
into its development.

I really don't want to write "Compilers for Dummies", but maybe that's
what I'm trying to write. :)

-Rich

P.S. You can check out the current unfinished state at
http://pennware.com/language/introduction.html

P.P.S. As a little background, I wrote compilers and assemblers,
linkers, etc. commercially for 20 years. I don't do that anymore, except
for fun.
 
N

Nick Keighley

[beginning programmer]
Try bash. It's very useful for system administration and contains
many of the basic constructs found in C. (or any programming language).

no. don't do this. bash very definitly isn't a good place to start
learning
to program. Learn with a proper programming language that is small and
with regular syntax. C is better than bash. I used to recommend Pascal
for
beginners but it seems to have become an obscure and bearly known
language,
I would have recomended Python, but you [the OP] have already tried
it.
Java?
 
O

Orhan Kavrakoglu

I like how he blames in on linux.

I love his honesty, yet he seems to be a bit ignorant, for the
"reader"'s message is much more correct. Should we compile and send an
explanation to him? :)
 
O

Old Wolf

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/linux/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);
}
 
B

Bernhard Holzmayer

Orhan said:
I love his honesty, yet he seems to be a bit ignorant, for the
"reader"'s message is much more correct. Should we compile and
send an explanation to him? :)

I guess he knows already - quite certainly others taught him.
I even suspect that he wrote this just to demonstrate good
companionship with the "dummy" he addresses.

Did anybody check if there's a footnote or such a thing which
mentions that the book is only for use on M$ Win... systems?

Bernhard
 
R

Randy Howard

Did anybody check if there's a footnote or such a thing which
mentions that the book is only for use on M$ Win... systems?

Isn't the term "for dummies" and "for use on "M$ Win" functionally
equivalent?
 
R

RCollins

Randy said:
I'll take your word for it.

<OT>
When used properly, the Windows platform can be used for (almost)
any purpose that other platforms can be used for. (Notice the key
phrase here: "when used properly").
You mean weasel?

Good catch! I've been using that sig for over a year, and nobody
noticed my goof -- or, at least, they didn't say anything.
 
M

Mabden

RCollins said:
Good catch! I've been using that sig for over a year, and nobody
noticed my goof -- or, at least, they didn't say anything.
weasel"

Shouldn't you credit Blackadder?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,145
Messages
2,570,826
Members
47,372
Latest member
LucretiaFo

Latest Threads

Top