type of character constants

Wayne A. Throop throopw at agarn.dg.com
Thu Mar 2 05:42:52 AEST 1989


> scm at datlog.co.uk ( Steve Mawer )
>> diamond at diamond. (Norman Diamond)
>> When you assign 'x' to a character, you are assigning an int to a
>> character.  The reader knows that the type mismatch was intentional.
> Not if he knows the C language.  A single character written within
> single quotes is a *character constant*.  This isn't an int.

Ha.  A lot Steve knows.  From K&R, 1st ed, pg 185

    Character constants have type int; floating constants are double.

>From Harbison and Steele, page 19

    Character constants have type int.

>From the latest dpANS C standard I have, 3.1.3.4, first sentence
under "semantics":

    An integer character constant has type int.

Strangely, I can't tell what type character constants have by reading
K&RII.  The references lead off to a note saying something like "...
and all constants have some type, see section mumble about types".
Section mumble talks about types alright, but nowhere does anything I
can find state just what constant forms have what types.  I wonder if
I'm missing something, or if this is a little oversight?

--
You will not see a monster {at Loch Ness},
just as millions before you have not.
                              --- Charles Kuralt
Wayne Throop      <the-known-world>!mcnc!rti!xyzzy!throopw



More information about the Comp.lang.c mailing list