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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The book is wrong. The standard does not specify if plain
charis 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 plaincharissignedorunsigned(ifCHAR_MINis less than 0 or equal to 0), but even then, the three types are distinct as far as the standard is concerned.Do note that
charis special in this way. If you declare a variable asintit is 100% equivalent to declaring it assigned int. This is always true for all compilers and architectures.