Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Differences between ANSI C and K&R C

721 views
Skip to first unread message

Richard D. Fong

unread,
Nov 12, 1996, 3:00:00 AM11/12/96
to

Folks,

Can anyone outline the differences between ANSI C and
K&R C?

Thanks in advance,
Rich

Ethan

unread,
Nov 13, 1996, 3:00:00 AM11/13/96
to Richard D. Fong

To: Richard D. Fong

Fr: Ethan

Subj: Re: Differences between ANSI C and K&RC

Richard,

One of the major extensions of ANSI C is the function prototype.In K&RC
one begins a
function definition by providing the name of the function and a list of
names to stand
for the parameters.In ANSI C parameters and their types appear together
in the function
heading.A function prototype is similar to a function heading except
that only the
types of the parameters appear.For example:

small(x,y) /* K&RC function heading */
small(int, int) /* ANSI C function prototype */
small(int x, int y) /* ANSI C function heading */

Hope this clear for you,
Ethan.

Alan D M

unread,
Nov 13, 1996, 3:00:00 AM11/13/96
to

I have been politely watching and reading from the sidelines, pausing only
to pat myself smugly on the back whenever some old programming salts tell
newbies to get a copy of the Kernighan-Ritchie opus on C.
Smug, because I've got a dog-eared copy of that tome. Then I read more
carefully: every "salt" tells a newbie to make sure to get the second
printing, or Volume 2. Does this mean I've got the right book but an old
version? Aaaaargh! Can't I get even that right?
ala...@hotstar.net

Billy Chambless

unread,
Nov 13, 1996, 3:00:00 AM11/13/96
to

You've got the 1978 version, which describes the language as of 1978.
The Second Edition follows the ANSI standard for C.

Gotta get it.

Of the zillions of dollars I've spent on various forms of programming
education, K&RII ws the best $32 I ever spent.

Shucks, that's cheaper than most Herb Schildt books, or any of the
"C in n Days" things out there!


Dan Pop

unread,
Nov 13, 1996, 3:00:00 AM11/13/96
to

In <56betk$o...@news.hotstar.net> "Alan D M" <ala...@hotstar.net> writes:

>I have been politely watching and reading from the sidelines, pausing only
>to pat myself smugly on the back whenever some old programming salts tell
>newbies to get a copy of the Kernighan-Ritchie opus on C.
>Smug, because I've got a dog-eared copy of that tome. Then I read more
>carefully: every "salt" tells a newbie to make sure to get the second
>printing, or Volume 2.

K&R2 actually denotes the second edition of the famous book.

>Does this mean I've got the right book but an old
>version? Aaaaargh! Can't I get even that right?

Difficult to tell, since we don't know what book you actually have.
Anyway, the full reference (cut & paste from the FAQ) is:

Brian W. Kernighan and Dennis M. Ritchie, _The C Programming Language_,
Second Edition, Prentice Hall, 1988, ISBN 0-13-110362-8, 0-13-110370-9.

Dan
--
Dan Pop
CERN, CN Division
Email: Dan...@cern.ch
Mail: CERN - PPE, Bat. 31 1-014, CH-1211 Geneve 23, Switzerland

Tim Behrendsen

unread,
Nov 13, 1996, 3:00:00 AM11/13/96
to

Richard D. Fong <tr...@hermit.chvpkh.chevron.com> wrote in article
<1996Nov1...@hermit.chvpkh.chevron.com>...

> Folks,
>
> Can anyone outline the differences between ANSI C and
> K&R C?

The Good Book, otherwise known as The C Programming Language,
by Brian W. Kernighan and Dennis M. Ritchie, Volume 2, which
you apparently do not have a copy of, has a brief section outlining
the differences.

Pick up a copy; you won't regret it.

--
==========================================================================
| Tim Behrendsen, Vice President | t...@a-sis.com |
| Air-Shields Information Systems | http://www.cerfnet.com/~timb (New!) |
==========================================================================

Phil Tregoning

unread,
Nov 14, 1996, 3:00:00 AM11/14/96
to

bi...@cast.msstate.edu (Billy Chambless) writes:
>"Alan D M" <ala...@hotstar.net> writes:
>> [...]

>> Does this mean I've got the right book but an old
>> version? Aaaaargh! Can't I get even that right?
>
> You've got the 1978 version, which describes the language as of 1978.
> The Second Edition follows the ANSI standard for C.
> [...]

I've got an old K&R2 from 1988, based on "Draft-Proposed ANSI C", which
includes in the introduction:

"At the time of writing, the standard was in the final stages of public
review; it is expected to be approved late in 1988. Differences between
what is described here and the final form should be minimal"

Does anyone know what these differences are ?

-------------------------------------------------------------------------
Phil Tregoning | (2*b) || !(2*b);
ESA ESRIN, Italy | That's not the question, it's a tautology!
ptre...@esrin.esa.it | Tim Hollebeek, Princeton
-------------------------------------------------------------------------

Dan Pop

unread,
Nov 14, 1996, 3:00:00 AM11/14/96
to

In <56er3n$j...@news.esrin.esa.it> treg...@pcsvx7.esrin.esa.it (Phil Tregoning) writes:

>I've got an old K&R2 from 1988, based on "Draft-Proposed ANSI C", which
>includes in the introduction:
>
>"At the time of writing, the standard was in the final stages of public
>review; it is expected to be approved late in 1988. Differences between
>what is described here and the final form should be minimal"
>
>Does anyone know what these differences are ?

Date: Thu, 8 Dec 94 01:44 EST
From: d...@research.att.com
To: dan...@mail.cern.ch
Subject: the errata list

Here is what we've accumulated. The file hasn't changed
since July 1992.
Page numbers could be off by a tiny amount.

Dennis
-----
Changes to The C Programming Language, 2nd Edition

As the C standard wended its way through the approval
process and become final, Brian and I prepared fixes to put
in new printings of the second edition of ``The C
Programming Language.'' These printings are identified by a
large red ``ANSI C'' on the upper right front corner.
Fortunately, the changes are minor; some repair our bugs, a
few account for last-minute changes in the draft standard.
For the benefit of previous and near-future purchasers, here
are the changes that were made:

Two or three sentences in the Preface and Introduction are
updated to describe the state of the Standard.

atof is in <stdlib.h>, not <math.h>; this changes 71, 76,
82, 121.

On page 86, error corrected: missing automatic initializers
are zero too.

On page 168: changed 1 to 1.0 to avoid potential overflow.

Minor typos are corrected on pages 87, 89, 164, 165, 168,
180.

The inconspicuous references to noalias on pages 192 and
211 are removed.

The following paragraph is added to the end of section A6.6
(p 199):

A pointer may be converted to another pointer whose
type is the same except for the addition or removal of
qualifiers (A4.4, A8.2) of the object type to which the
pointer refers. If qualifiers are added, the new
pointer is equivalent to the old except for
restrictions implied by the new qualifiers. If
qualifiers are removed, operations on the underlying
object remain subject to the qualifiers in its actual
declaration.


On p. 199, beginning of section A6.8, ``Any pointer may be
converted to type void *...'' is changed to ``Any pointer
>to an object< may be converted to type void *...''.

On p. 204, A7.4.4, ``The operand of the unary + operator
must have arithmetic or pointer type...'' should read ``must
have arithmetic type...''.

On p. 206, A7.9, about relational operators: ``Pointers to
objects of the same type may be compared...'' is changed to
``Pointers to object of the same type >(ignoring any
qualifiers)< may be compared...''.

The indented material on p. 209, ``According to the
restrictions... relaxing it.'' is removed. [This is
related to the paragraph added above. The wording of the
penultimate draft made it useless to take an (int *)
pointer, cast it to (const int *), then cast it back to
(int *).]

On p. 219 middle, initialization of structures, add
``Unnamed bit-field members are ignored, and are not
initialized.''


Appendix B changes:

p 242: Add ``fflush(NULL) flushes all output streams.'' to
fflush description.

p 243: Change to ``it must be called before reading,
writing >or any other operation<'' in setvbuf description.

p 249: Add ``Comparison functions treat arguments as
unsigned char arrays.'' to <string.h> description.

p 255: Change range of tm_sec to (0,61) for leap seconds.

p 255: Change CLK_TCK to CLOCKS_PER_SEC.

p 257: Drop U and L suffixes from <limits.h> constants.
tm_sec range is (00,61) here too.

Appendix C change:

p 261: Change ``External declarations without any
specifiers...'' to ``External >data< declarations without
any specifiers...''.

The index has been reprinted to fix a couple of typos and
account for motion within Appendix A; one page of the table
of contents is changed.


October, 1989: Minor changes on page 131 to add & to last
example, on page 208 to change ``equal'' to ``unequal'' in
the description of logical OR, and on page 254 to clarify
that only volatile automatics are saved with longjmp.

Not yet fixed in any printing:

page 53: Note under the table should say & as well as + - *
has higher precedence as a unary operator.

page 111: indent is too large, and a bit of program text is
cut off.

page 231 extra right paren in nested call to cat macro.

page 246: first argument of sscanf should have type
const char *.

page 249: in description of strncpy, t => ct.

There is no mention of the offsetof macro, and should be.

The scanf functions do not ignore white space in formats.

p. 49 shifts: `which must be positive' -> `which must be non-negative'

Roger L. Cordes, Jr.

unread,
Nov 15, 1996, 3:00:00 AM11/15/96
to

Alan D M wrote:

> ...old programming salts tell newbies to get a copy of the
> Kernighan-Ritchie opus on C [and] to make sure to get the second
> printing... Does this mean I've got the right book but an old
> version?

No, this means that you and I are the only ones left that have the
*right* version ;^)

Maybe,
R.

prad...@gmail.com

unread,
Mar 20, 2017, 9:42:17 AM3/20/17
to
On Tuesday, November 12, 1996 at 1:45:00 PM UTC+5:45, Richard D. Fong wrote:
> Folks,
>
> Can anyone outline the differences between ANSI C and
> K&R C?
>
> Thanks in advance,
> Rich
the major difference betwween ansi c and k&rc are:
1>function prototyping
2>support of the const and volaile data type qualifer
3>support wide character and internationalization
4> permit function pointer to be used without deferencing

GOTHIER Nathan

unread,
Mar 20, 2017, 10:02:17 AM3/20/17
to
ANSI C aka C90 doesn't include wide character support IIRC.

mark.b...@gmail.com

unread,
Mar 20, 2017, 11:19:49 AM3/20/17
to
I'm sure that after nearly 21 years, the OP is thrilled at
your comprehensive, articulate response.

Keith Thompson

unread,
Mar 20, 2017, 11:25:48 AM3/20/17
to
You're replying to an article that was posted more than 20 years ago.

--
Keith Thompson (The_Other_Keith) ks...@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
0 new messages