What is an unsigned char?

后端 未结 17 1156
借酒劲吻你
借酒劲吻你 2020-11-22 11:05

In C/C++, what an unsigned char is used for? How is it different from a regular char?

17条回答
  •  清酒与你
    2020-11-22 11:28

    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.

提交回复
热议问题