[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Book questions

On 14/04/2015, Reco <recoverym4n@gmail.com> wrote:
> On Tue, Apr 14, 2015 at 12:36:28AM +0800, Bret Busby wrote:
>> On 13/04/2015, Reco <recoverym4n@gmail.com> wrote:
>> <snip>
>> >Learning C is simple and
>> > fun. Just read classic K&R treatise, do all the examples. Did so back
>> > in
>> > high school, and no brain was damaged in the process :)
>> > The only problem today is to get a C compiler that understands K&R C.
>> >
>> I have not programmed in "C" for about 20-25 years, now, but, from
>> memory, with compilers, like "C" compilers, don't they have a switch
>> that can be set,  so that they accept only ANSI code, such as ANSI
>> "C"?
> *ANSI* C - yes. For instance, gcc has this wonderful '-ansi' switch.
> It's even possible to choose the exact version of ANSI C standard (i.e.
> -std=c99).
> *K&R* C - no. At least, gcc-4.7 has no switch for this that I'm
> aware of.

Okay - this is where the detail of the Kernighan & Ritchie book, is required.

You see, when I searched for "C" books, at amazon, I found at

The C Programming LanguageApr 1, 1988
by Brian W. Kernighan and Dennis M. Ritchie

The authors present the complete guide to ANSI standard C language
programming. Written by the developers of C, this new version helps
readers keep up with the finalized ANSI standard for C while showing
how to take advantage of C's rich set of operators, economy of
expression, improved control flow, and data structures. The 2/E has
been completely rewritten with additional examples and problem sets to
clarify the implementation of difficult language constructs. For
years, C programmers have let K&R guide them to building
well-structured and efficient programs. Now this same help is
available to those working with ANSI compilers. Includes detailed
coverage of the C language plus the official C language reference
manual for at-a-glance help with syntax notation, declarations, ANSI
changes, scope rules, and the list goes on and on.

So, the second edition, published in 1988, included ANSI "C", and, the
picture of the from cover of the book, has a big stamp on it; "ANSI

So, it really depends on, if the original poster obtains, or, obtains
access to, a copy of the text "The C Programming Language" by
Kernighan and Ritchie, whether he gets a copy that is the second
edition (1988) or later.

If he gets a copy that is the second edition (1988), or later, then it
should be ANSI "C".

When I was learning "C", I found the (then available) Sam's Waite
Group "C" Bible to be a brilliant reference manual, as it was a
brilliant language reference manual.

But, a reference manual, and, a teaching course, are two different things.

And, one thing that I learnt, when I was learning 3GL programming
laguages, was that it was best, to stick to ANSI standard language,
for portability. Thus, when I wrote code to run on VAX11-VMS, or
PDP11-RSTS/e or UNIX SVR4 or CM/CMS  (I think it was) running on an
IBM-3081, or my PC-XT running DOS, the code would mostly run
unaltered, on each. As an example, I compared the processing speed of
my PC-XT, with the IBM-3081, during a vacation, with not many other
students around, running a Pascal program to approcimate pi using a
Chebyshev (I think that is the correct spelling) series approximation,
and the average speed, per minute, was, for the IBM3081, about 10
million iterations, and, on my PC-XT, about 10,000 iterations. Using
ANSI standard code, meant that the same code could be used on each
system. I believe that, if a person learns programming in a 3GL, it is
best to adhere to the ANSI standard for the language, if an ANSI
standard exists for the language, for portability.

Bret Busby
West Australia

"So once you do know what the question actually is,
 you'll know what the answer means."
- Deep Thought,
 Chapter 28 of Book 1 of
 "The Hitchhiker's Guide to the Galaxy:
 A Trilogy In Four Parts",
 written by Douglas Adams,
 published by Pan Books, 1992


Reply to: