Why does C use `char` rather than `BYTE`?
Other programming language used BYTE
for using Byte data type.
// in Visual BasicDim byteValue1 As Byte = 201 Console.WriteLine(byteValue1) Dim byteValue2 As Byte = &H00C9 Console.WriteLine(byteValue2) Dim byteValue3 As Byte = &B1100_1001 Console.WriteLine(byteValue3)
And C use char
. But char
mean ‘Character’ which means string data type.
// in Cunsigned char temperatura;
temperatura = -2;
signed char edad;
edad = 52;
But, why?
When C was born, they wanted to emphasize that the 1-byte data type is fit on ASCII code. Cuz 1-byte can contains 256 kinds of numbers. So, who invented C wants to express that when they declare 1-byte. That’s why they put the name char
on that.
the Problem with that
Many beginners who learn C
confused by the name. 1-byte also fits on small numbers. For example, ages, temperature, and some scores. But by the name, it seems like we need to use int
. But int
is too big for small ones.
So it's better to use char
for small numbers. But semantically it's not correct. Because anyway, Char stands for character. This is an irrational element that has existed since the beginning of C.