Почему литералы символов C являются целыми, а не символами?C++

Программы на C++. Форум разработчиков
Anonymous
Почему литералы символов C являются целыми, а не символами?

Сообщение Anonymous »


В C++

Код: Выделить всё

sizeof('a') == sizeof(char) == 1
. This makes intuitive sense, since is a character literal, and

Код: Выделить всё

sizeof(char) == 1
as defined by the standard.

In C however,

Код: Выделить всё

sizeof('a') == sizeof(int)
. That is, it appears that C character literals are actually integers. Does anyone know why? I can find plenty of mentions of this C quirk but no explanation for why it exists.


Источник: https://stackoverflow.com/questions/433 ... d-of-chars

Вернуться в «C++»