As opposed to C++, In C, a character literal is implemented as to be always of type int
.
But why we have then the type of char
for holding a character value?
In the question Why are C character literals ints instead of chars?,
it is discussed, why character literals are of type int
in C. But this is not what my question is about.
Inside the question If character constants are of type `int', why are they assigned to variables of type `char`? then it is going a little more into the deep with the question, why we actually assign character literals to variables of type char
if they are of type int
, but the provided answers left the concern, why we need the type of char
in general.
My Questions are now:
- Why we have the type of
char
if any character literals are always ofint
type? - Isn´t the type of
char
redundant then? - What is the purpose of type
char
, if it is seemingly redundant?