Char vs. Int

Jay Mathew Libove jl42 at andrew.cmu.edu
Sat Sep 13 18:18:38 AEST 1986


I have always been under the impression that a CHAR variable and an INT variable
were the same in 'C'- yet I now see:

Message-Id: <1219 at drutx.UUCP>
Date: 8 Sep 86 02:52:47 GMT
To: info-c at brl-smoke.arpa

In the sequence:

	main()
	{
		char c = 'w';
		foo(c)
	}

	foo(ch)
	char ch;

char ch is the correct declaration.  The compiler/code generator should
handle pulling the character portion of the promoted variable off the
stack correctly.  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
same?



More information about the Comp.lang.c mailing list