I was looking at the data types at the link data type
It is written as char type is 1 byte having a range -128 to 127 or 0 to 255.
How can this possible? By default char
means signed right.
Edit: There is another question Whats wrong with this C code?. But it is not same question. Title says what is wrong with this code and search will not list this answer easily. One has to analyse the question fully to understand the issue.
Edit: After looking at several answers and comments, I got another doubt. Strings within double quotes are treated as char. I get warnings if I pass double quoted strings to a function having parameter of type signed char. Also itoa and many other library functions make use of char type parameter and not signed char. Ofcourse typecasting will avoid this problem. So what is the best parameter type for functions manipulating null terminated strings(for example LCD display related functions)? Use signed char or unsigned char (since char is implementation defined, it may not be portable I guess)