Why does C use `char` rather than `BYTE`?

TheDevStory
1 min readOct 29, 2022

c language

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.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

TheDevStory
TheDevStory

Written by TheDevStory

A web developer crafting online experiences. Also football(soccer) coach and Spanish Learner.

Responses (5)

Write a response

You would be using uint8_t for bytes, char for actual characters, and so on.

--

A byte type would presume 8 bits. There is nothing in C or C++ that requires that a byte has 8 bits. 7 bits or even 6 bit char types used to exist. iIf you want a byte type, use int8_t or uint8_t (just #include <std_types.h>)

--

These days (indeed for decades now) you would use int which would be sized for the platform you are on. This is because of efficiency, alignment, etc. Later on C started to use size_t for the same.

You’d use char, byte, uint8, u8 (etc) where the…

--