C++ char type length and size
hello i have some questions about c++ variable type (char).
i read in some sites that this char support range from (-128 to 127) and in unsigned (0 to 255). what is this mean?
char support not just numbers so why they say (-128 to 127) ?
what mean this range ??
range for what?
my other question is: when i can use this
const char * Data;
Data = "dddddddddddddddddddddddddddddddddddddddddddddddde21312313dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddde21312313dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddde21312313dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddde21312313dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddde21312313dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd";
why we need to set unsigned or signed or ... before char?
with this action (using *
too) system automatic detect length of char and keep size of storage in normal and standard size ... why we need to set size like (char Data[255])
when we can do this and have dynamic size and skip static size?
or with this action why we need ( wchar_t
) anymore ??? !
char support not just numbers so why they say (-128 to 127) ?
Actually, you're wrong. char
s are just numbers. You are thinking of the ASCII representation of those numbers. For example, what you see as d
is actually the number 100.
So, it is true to say that the only values a signed char
can hold are in the range -128 → 127. However, the statement assumes that char
without a qualifier is signed, which is not always true.
上一篇: 你什么时候使用“signed char”而不是“unsigned char”?
下一篇: C ++字符类型的长度和大小