"a book on c" Kelly & Pohl (4e)

E

Ernie Wright

J. J. Farrell said:
Not in that detail, of course. But why would you want to complicatedly
mislead the reader then correct it later, when you could just explain
it more simply and correctly from the outset?

Because the allegedly simple explanation is that headers are magic,
which is no explanation at all.
#include <stdio.h>

tells the compiler that you are intending to use the Standard I/O
library facilities, and it makes the compiler aware of all the
information it needs to do so.

Why does the compiler need to be told this? Can't it figure this out by
itself? Is stdio.h a library? Why angle brackets and not quote marks?
What does "#include" mean? What is "Standard I/O" and why do I need it?

If you don't give beginners something concrete to hold onto, they can
quickly be carried away on the winds of scrupulous vagueness and opaque
abstraction.

- Ernie http://home.comcast.net/~erniew
 
S

Shapalov

is this book good for learning C ?

i am a beginning programmer, Kernighan and Ritchie 2e is quite hard on
me.

Bradley L.Jones and
Peter Aitken

" C in 21 days "
 
P

pete

Why not?
I think it's best to get it right from the begining.
The removal of an important bit of context from what I wrote here has
created a straw man. To restore this bit of context, after "...to a
beginner?", add "On page 5?".


It's pretty clear that lcw1964 wasn't on page
5 of an introductory book
on C programming when he asked his original question in that thread.
In fact, he appears to have gotten pretty far
without knowing that headers aren't necessarily files.
His misconception was easily corrected and
not particularly harmful.

lcw1964's misconception was easily corrected because lcw1964
posted to this newsgroup, where misconceptions are corrected;
and which is why I wrote what I wrote in this thread.

lcw1964 wouldn't even attempt to compile
the code example in question, until after
lcw1964 argued that it was nonportable and got corrected.

I don't understand what harm you see in stating
the facts correctly from the start.

It's just really not that complicated:
1) It is called a "header".
2) It need not be a plain file.
 
C

CBFalconer

Ernie said:
The removal of an important bit of context from what I wrote here
has created a straw man. To restore this bit of context, after
"...to a beginner?", add "On page 5?".

This illustrates something about which I periodically indulge in
beard muttering. Snippage should be in units of paragraphs.
 
S

santosh

arnuld said:
have you checked ACCU ?


one last piece of advice: stay away from "amazon" reviews. i wasted
thousands of rupees by trusting them :-(

Why do you buy from Amazon? Usually, special versions of those books,
printed and meant to be sold within the Indian subcontinent are
available in most bookshops. They're considerably cheaper than their
original printings, as long as you can live with a paperback and
somewhat cheaper paper.
 
R

Richard Heathfield

santosh said:
It's actually "Teach Yourself C in 21 Days."

Followed by several years of discovering why attempting to do it in 21
days was a mistake. Better to get a decent book that doesn't
artificially raise your hopes at the start.
 
J

J. J. Farrell

Because the allegedly simple explanation is that headers are magic,
which is no explanation at all.



Why does the compiler need to be told this?

Because, in a very limited sense, putting this line in switches the
compiler to understand a particular dialect of C - certain terms
become reserved, for example, and various important facilities become
available.
Can't it figure this out by itself?

No. It can't tell whether or not I want it to compile this "dialect"
unless I tell it.
Is stdio.h a library?

No, that's one of a large number of things that it's not. The list
begins with aardvark.
Why angle brackets and not quote marks?

Or excalamtion marks, or upside down question marks? Because that's
how the specifiers of the language specified it.
What does "#include" mean?

In this context, what I said. It can also be used for other things
which will be introduced later.
What is "Standard I/O" and why do I need it?

Easily answered.

Just how would incorrectly telling them that stdio.h is a file help
with any of these questions? They can all be answered at this point if
necessary without any need to go wandering off into incorrect and
irrelevant information about reading in files.
If you don't give beginners something concrete to hold onto, they can
quickly be carried away on the winds of scrupulous vagueness and opaque
abstraction.

Indeed, but how does giving them incorrect information which doesn't
even answer any of their questions help?
 
A

arnuld

Why do you buy from Amazon? Usually, special versions of those books,
printed and meant to be sold within the Indian subcontinent are
available in most bookshops. They're considerably cheaper than their
original printings, as long as you can live with a paperback and
somewhat cheaper paper.

YES, you are right and MOST of these books are not available in India.
take these as examples:

Practical Common Lisp [1], C: A Reference Manual by H&S, C: A Modern
Approach by K.N. King, PAIP [2], Introduction to computing and
algorithms by Shackleford
[3], Data Structures and Algorithms in C++ by Adam Drozdek [4] & many
many other important books.

in 40% of the cases i have alternatives available but for the rest, no
option and when people say India is a high-tech country then i feel :-
( because our basic problems are still here e.g. In well known city,
Chandigarh, no matter which college you join:

1.) nobody had ever heard of K&R, they just use "Let Us C" by Kanitkar
[5].
2.) they teach a language named VC++, if you say "ok, you are learning
C++", then students *quickly* reply: "NO, i am learning VC++ language,
not C++"

sadly, they are also learning "Turbo C" with "conio.h", the Standard
Library

BTW, who is this "K.N.King" and "Harbison" and "Steele". what the heck
is "C unleashed"

it *is* my Hi-Tech country

:-(



-- arnuld
http://arnuld.blogspot.com

[1] http://www.gigamonkeys.com/book/
[2] http://norvig.com/paip.html
[3] http://www.accu.informika.ru/bookreviews/public/reviews/0sb/algorithms.htm
[4] http://www.accu.informika.ru/bookreviews/public/reviews/0sb/algorithms.htm
[5] http://www.sapnaonline.com/MoreInfoBK.aspx?lcID=EBK0008879
 
C

CBFalconer

arnuld said:
.... snip ..

BTW, who is this "K.N.King" and "Harbison" and "Steele". what the
heck is "C unleashed"

"C Unleashed" is a light weight (under two tons) tome authored by
R. Heathfield and associates.
 
E

Ernie Wright

J. J. Farrell said:
Just how would incorrectly telling [beginners] that stdio.h is a file
help with any of these questions?

Because that's how people learn. We start with the concrete and simple
and progress to the abstract and elaborate. The original simple idea
becomes the archetype of a category. We start with stdio.h as a file,
and progress to #include <stdio.h> being file-insertion-like in its
effect.

We teach first graders that you can't subtract a bigger number from a
smaller one, then later tell them about negative numbers. We say that
you can't take the square root of a negative number, then tell them that
not only can this be done, it has a physical meaning applied daily in
physics and electrical engineering. We teach Newton before Einstein and
the Bohr atom before the Schrödinger atom.

If this weren't the way people learn, then we wouldn't have any need for
books about C. We could all learn directly from the Standard, and our
understanding of C would emerge fully formed. We'd all be instant
experts.

In light of all this, "stdio.h is a file" is *not* incorrect. It is
*incomplete*. It is squarely on the path to the truth in a way that
"stdio.h is a library" and "stdio.h is an aardvark" are not.

- Ernie http://home.comcast.net/~erniew
 
E

Ernie Wright

pete said:
I don't understand what harm you see in stating
the facts correctly from the start.

See my reply to J. J. Farrell.

As for harm, I understood your initial post in this thread to be, not
merely an interjection of correctness, but a criticism of Kelley and
Pohl, and I think it may turn beginners away from a good book that they
might find more accessible than K&R2.

- Ernie http://home.comcast.net/~erniew
 
T

Tor Rustad

pandit said:
is this book good for learning C ?

i am a beginning programmer, Kernighan and Ritchie 2e is quite hard on
me.

I learned to program in C from it, as a physics student I really liked
the style and especially the exercises in it. After nearly 20 years, I
still remember some of those excellent exercises... particularly the
Hamilton path & knights tour problems. So hard, that you knew not all
students would make it. Great!

A Book on C, is not the best choice for a CS student, for for others it
can open their eyes into the fun of C programming. But.. do read K&R2
afterwards!
 
D

David Thompson

Because that's how people learn. We start with the concrete and simple
and progress to the abstract and elaborate. <snip>
In light of all this, "stdio.h is a file" is *not* incorrect. It is
*incomplete*. It is squarely on the path to the truth in a way that
"stdio.h is a library" and "stdio.h is an aardvark" are not.
However, 'aardvark' is the name of the change management tool used by
The Austin Group, which developed and maintains the recentlyish-merged
POSIX/XPG standard, which effectively incorporates and extends C, and
thus in that somewhat limited context it sometimes makes sense to say
'this is a stdio.h aardvark'. <G><?>
 
J

Jan Werner

is this book good for learning C ?

i am a beginning programmer, Kernighan and Ritchie 2e is quite hard on
me.
"Pointers on C" by Kenneth A. Reek is, IMHO, the best introductory book
on C programming that I have seen, a sentiment I was gratified to see
echoed almost word for word by Francis Glassborrow in his ACCU review.

However, Glassborrow believes that "Pointers on C" is best suited for
someone with some prior programming experience. I'm not sure I agree,
but a good choice for a beginning programmer might be the "C Primer
Plus, 5th Edition" by Stephen Prata. In spite of its misleading title,
this book teaches C, not C++, but it also does take the time to explain
where the languages diverge.

Jan Werner
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top