Signed char - What Foolishness Is This!

Joseph S. D. Yao jsdy at hadron.UUCP
Fri Nov 7 16:35:33 AEST 1986


In article <228 at apple.UUCP> mikes at apple.UUCP (Mike Shannon) writes:
>In <8719 at duke.duke.UUCP> jwg at duke.UUCP (Jeffrey William Gillette) writes:
>>MSC 4.0 defaults 'char' to 'signed char'.  ...
>>             This works great when c = 65 ('A'), but when c = 154
>>('U'umlaut) the macro produces the following: ( (_ctype+1)[-102] & UPPER )
>> ....

The standard (K&R, and now X3J11) has always held that 'char' is
signed or unsigned, depending on the machine.  For good, usable,
portable code I've tended to do arithmetic ops (such as indexing
an array) in shorts or ints, masking input chars.  This is also
great for testing EOF ...  Also, the ctype macros should NOT be
used with any char > 0177, simply because many or most current
implementations only use a buffer that large.
-- 

	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