Char vs. Int

Joseph S. D. Yao jsdy at hadron.UUCP
Tue Sep 23 15:47:24 AEST 1986

In article <3770 at brl-smoke.ARPA> jl42 at (Jay Mathew Libove) writes:
>I have always been under the impression that a CHAR variable and an INT variable
>were the same in 'C'- yet I now see:
>In the sequence:
> ...
>char ch is the correct declaration.  ...
>		.  Declaring it 'int' is asking for trouble.
>Why is it asking for trouble to declare ch as INT when K&R says they are the

Simple.  It doesn't and they aren't.  K&R 2.2: char is a byte, one
character; int is the machine's natural integer (and examples).
K&R 2.7 mentions chars' automatic conversion, in arithmetic and
arguments, into ints.  (The need for conversion, of course, implies
the difference between the two.)  This is repeated in CRef 2.6,
4., 6.1, 6.6.

	Joe Yao		hadron!jsdy at seismo.{CSS.GOV,ARPA,UUCP}
			jsdy at hadron.COM (not yet domainised)

More information about the Comp.lang.c mailing list