Florian Weingarten wrote:
At_sea_with_C <bl********@dev.null.invalidwrote:
>Is there a reason to prefer char over signed or unsigned char. From waht I
know all strings can be coded with unsigned char while a negative number
can be put in signed char. So what are the uses for plain char?
As far as I know, there is no "plain char".
`char` is plain.
A char is either a unsigned char or a signed char, which exactly
is implementation depenedent:
ISO/IEC 9899:1999, 6.2.5.15 (p. 49)
The three types char, signed char, and unsigned char are collectively called
the character types. The implementation shall define char to have the same range,
representation, and behavior as either signed char or unsigned char.
No: it has the same range, representation, and behaviour as one of
those types, but it's a different type.
I'd expect the implementation to pick whichever one was "more
efficient" by some reasonable measure - eg when converting to
`int`, one probably wants an efficient code sequence, so one
picks whatever the machine conversion is (PDP11 MOVB, for example)
and takes the consequences.
--
Chris "electric hedgehog" Dollin
"We live for the One, you die for the One." Unsaid /Babylon 5/.