unsigned
suggest changeA type specifier that requests the unsigned version of an integer type.
- When used alone,
int
is implied, sounsigned
is the same type asunsigned int
. - The type
unsigned char
is different from the typechar
, even ifchar
is unsigned. It can hold integers up to at least 255. unsigned
can also be combined withshort
,long
, orlong long
. It cannot be combined withbool
,wchar_t
,char16_t
, orchar32_t
.
Example:
char invert_case_table[256] = { ..., 'a', 'b', 'c', ..., 'A', 'B', 'C', ... };
char invert_case(char c) {
unsigned char index = c;
return invert_case_table[index];
// note: returning invert_case_table[c] directly does the
// wrong thing on implementations where char is a signed type
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents