無符號
請求無符號版本的整數型別的型別說明符。
- 單獨使用時,暗示
int,因此unsigned與unsigned int的型別相同。 unsigned char的型別與char的型別不同,即使char是無符號的。它可以保持至少 255 的整數。unsigned也可以與short,long或long long結合使用。它不能與bool,wchar_t,char16_t或char32_t結合使用。
例:
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
}