+ 5
Char vs unsigned char
I know we have Three type of char In C/C++,char, unsigned char and signed char. what an unsigned char is used for? And Can you give an example? How is it different from a regular char?
3 ответов
+ 5
A signed char is same as an ordinary char and has a range from -128 to +127; whereas, an unsigned char has a range from 0 to 255. ... Similarly, a signed char in C/C++ is a type stored in 1 byte (same as above) which can hold an integer which may be either positive, zero or negative.
additional references:
https://stackoverflow.com/questions/4337217/difference-between-signed-unsigned-char
Example provided:
https://www.geeksforgeeks.org/unsigned-char-in-c-with-examples/
+ 4
Thanks for your reply
+ 3
unsigned char is a character datatype where the variable consumes all the 8 bits of the memory and there is no sign bit (which is there in signed char). So it means that the range of unsigned char data type ranges from 0 to 255.
while signed char is from - 128 to 127
https://stackoverflow.com/questions/75191/what-is-an-unsigned-char