int main(void) { printf("%d",(int)'А'); } In theory, the program should display the code 'A' (Cyrillic), i.e. 192, but for some reason prints -64.
int main(void) { printf("%d",(int)'А'); } In theory, the program should display the code 'A' (Cyrillic), i.e. 192, but for some reason prints -64.
The char type can behave either as a signed char type or as an unsigned char type, depending on the compiler options installed.
In your case, the char type behaves like the signed char type.
For the type signed char maximum positive value is 127 or hexadecimal 0x7F .
If you want to get a positive code value, then write
printf("%d",(unsigned char)'А'); At the same time, the Russian letter should not be represented as a multibyte constant.
Source: https://ru.stackoverflow.com/questions/589165/
All Articles
unsigned int. - Mike