無符號

請求無符號版本的整數型別的型別說明符。

  • 單獨使用時,暗示 int,因此 unsignedunsigned int 的型別相同。
  • unsigned char 的型別與 char 的型別不同,即使 char 是無符號的。它可以保持至少 255 的整數。
  • unsigned 也可以與 shortlonglong long 結合使用。它不能與 boolwchar_tchar16_tchar32_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
}