Is char signed or unsigned by default?

前端 未结 7 807
佛祖请我去吃肉
佛祖请我去吃肉 2020-11-21 06:49

In the book \"Complete Reference of C\" it is mentioned that char is by default unsigned.

But I am trying to verify this with GCC as well as Visual Stud

7条回答
  •  悲哀的现实
    2020-11-21 07:27

    C99 N1256 draft 6.2.5/15 "Types" has this to say about the signed-ness of type char:

    The implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char.

    and in a footnote:

    CHAR_MIN, defined in , will have one of the values 0 or SCHAR_MIN, and this can be used to distinguish the two options. Irrespective of the choice made, char is a separate type from the other two and is not compatible with either.

提交回复
热议问题