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 Studio. It is taking it as signed by default.
Which one is correct?
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 Studio. It is taking it as signed by default.
Which one is correct?
The book is wrong. The standard does not specify if plain
char
is signed or unsigned.In fact, the standard defines three distinct types:
char
,signed char
, andunsigned char
. If you#include <limits.h>
and then look atCHAR_MIN
, you can find out if plainchar
issigned
orunsigned
(ifCHAR_MIN
is less than 0 or equal to 0), but even then, the three types are distinct as far as the standard is concerned.