type of character constants

T. William Wells bill at twwells.uucp
Sat Mar 11 21:34:21 AEST 1989


In article <1644 at vicorp.UUCP> charlie at vicorp.UUCP (Charlie Goldensher) writes:
: So what does it matter if a character constant is of type char or of
: type int?  If it is of type char, it will be *converted* to type int
: in any expression in which it is used.  And if it is of type int it
: will be implicitly cast to type char if it assigned to a variable of
: type char.
:
: I don't care how the compiler writer chooses to implement it internally
: as long as they follow the appropriate conversion rules.
:
: Is there some reason I *should* care?

There is a subtle difference. If 'c' is an integer constant, '\377'
represents the value 255. If, on the other hand, it is a char
constant, and characters sign extend, it represents -1.

---
Bill
{ uunet | novavax } !twwells!bill
(BTW, I'm going to be looking for a new job sometime in the next
few months.  If you know of a good one, do send me e-mail.)



More information about the Comp.lang.c mailing list