unsigned
suggest changeA type specifier that requests the unsigned version of an integer type.
- When used alone,
intis implied, sounsignedis the same type asunsigned int. - The type
unsigned charis different from the typechar, even ifcharis unsigned. It can hold integers up to at least 255. unsignedcan 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