On 31-Dec-01, 16:30 (CST), Peter Finderup Lund <[EMAIL PROTECTED]> wrote: > On 31 Dec 2001, Colin Walters wrote: > > No, the C standard guarantees that a char is exactly a single byte; i.e. > > sizeof(char) == 1. > > I think he meant "wider than one would think"-character. A char didn't > originally have to be 8 bits wide -- the first edition of K & R "The C > Programming Language" explicitly mentions an implementation with 9-bit > chars. > > I think the newer standards say you have to use 8-bit chars but with some > sort of "cat flap" clause that allows exceptions if the platform is a > weird DSP or something like that.
Nope, the standard says that 1. sizeof(char) == 1 2. the range of signed char is *at least* -127 -> +127 3. the range of unsigned char is *at least* 0 -> 255 4. "plain" char shall act like one of (2) or (3) The net effect is that chars are *at least* 8 bits wide, but may be wider. The macro "CHAR_BIT" in limits.h will tell if if you really need to know. There is no requirement that char be exactly 8 bits; no cat flap required. Steve