Newsgroups: comp.lang.c Path: utzoo!utgpu!jarvis.csri.toronto.edu!dgp.toronto.edu!flaps From: flaps@dgp.toronto.edu (Alan J Rosenthal) Subject: Re: type of character constants Message-ID: <8903140309.AA02400@champlain.dgp.toronto.edu> Keywords: character constants Organization: Dynamic Graphics Project, University of Toronto References: <13068@steinmetz.ge.com> <102@servio.UUCP> <10138@socslgw.csl.sony.JUNET> <1783@dlvax2.datlog.co.uk> <3711@xyzzy.UUCP> <1644@vicorp.UUCP> Date: Mon, 13 Mar 89 22:09:04 EST charlie@vicorp.UUCP (Charlie Goldensher) writes: >On the previous page (page 184, 6.6 Arithmetic conversions) K&R say: > > First, any operands of type char or short are converted to > type int, and any of type float are converted to double. > >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... It affects sizeof 'a', which is sizeof(int), not sizeof(char). bill@twwells.uucp (T. William Wells) writes: >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. Nope, it is an int constant, and if chars are 8 bits and the system is twos complement and chars sign-extend, it is -1. Reference: K&R II p193, second-to-last sentence of the last full paragraph. ajr -- "The goto statement has been the focus of much of this controversy." -- Aho & Ullman, Principles of Compiler Design, A-W 1977, page 54.