$2.35

Why are character literals ints in C ?

Ask a question+
0

In C++ sizeof('a') == sizeof(char) == 1 .
However, in C sizeof('a') == sizeof(int) .
Why ?

Tigran 1.2K
add comment

1 Answer

0

I think a character in c is represented with int. The character has a code point. The code point is an index of the character in the encoding. Such as character a have code point 97 or U+0061 in unicode. In c, the code point is used to represent char as an integer. Maybe my statement is correct.

Levi Rizki 170
add comment

Your Answer