> > > In K&R C (I don't know from
ANSI), it was recommended that an int be
> > > whatever type was easiest to deal with.
> > ISO C section 6.2.5 paragraph 5 says about the int type:
> K&R .NE. ANSI
> K&R .NE. ISO
> NOTE: "K&R" refers to edition ONE.
> Later, K&R wrote a different book to document a different language
(called
"ANSI-C")
On Wed, 1 Feb 2012, Sean Conner wrote:
How does K&R C (which I don't consider C)
differ from ANSI-C? I mean,
besides function prototypes, formal variable argument functions and a
standardize library of functions I can rely upon to exist?
-spc (struggling with C code at work that at one point must have been K&R,
and it shows ... ugh)
(I guess that any use of "C" without further qualification will result in
confusion)
There are certainly many similarities, a programmer who knows one will not
have MUCH difficulty learning the other. In fact, some K&R1-C programs
could be written in ANSI-C, and some ANSI-C programs could be written in
K&R1-C. SOME programs could, in theory, be written to run in BOTH!
"Ansi C" has STANDARDS!
"K&R1 C" does NOT.
With ANSI-C, there are many things that you can assume.
With K&R1-C, there aren't.
Even down to things such as char >= 8 bits, and "everything can be made of
chars".
If one were sufficiently demented, K&R1-C could be implemented on machines
that not all would agree to call "computers". Because of that
flexibility, programming in K&R1-C requires MUCH greater knowledge of the
specific implementation, and ability to port to anything else is NOT a
given.
For specific items, such as integer multiples of size, I will now have to
retrieve one of my copies of K&R1 and go through systematically to try the
daunting task of "proof of non-existence" for numerous issues that have
been argued.
For any task that is thoroughly abstracted from the hardware, ANSI-C is
preferable, since you will know exactly what to expect. For tasks that
are VERY close to the hardware, K&R1-C permits use/ABUSE of implementation
specifics. IOW, are we going to compute Sales Tax?, or are we going to
twiddle bits?
--
Grumpy Ol' Fred cisin at
xenosoft.com