In C/C++, what an unsigned char
is used for? How is it different from a regular char
?
signed char
has range -128 to 127; unsigned char
has range 0 to 255.
char
will be equivalent to either signed char or unsigned char, depending on the compiler, but is a distinct type.
If you're using C-style strings, just use char
. If you need to use chars for arithmetic (pretty rare), specify signed or unsigned explicitly for portability.