+ 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?

22nd Feb 2020, 1:44 PM
hossein B
hossein B - avatar
3 odpowiedzi
+ 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/
22nd Feb 2020, 1:50 PM
BroFar
BroFar - avatar
+ 4
Thanks for your reply
22nd Feb 2020, 2:08 PM
hossein B
hossein B - avatar
+ 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
22nd Feb 2020, 1:47 PM
Gordon
Gordon - avatar