#include <stdio.h>
int main(void) {
int nr = 5;
char castChar = (char)nr;
char realChar = '5';
printf("The value is: %d\n", castChar);
}
If the above code is compiled, the output will be:
The value is: 5
But if the code below is compiled, the console will output the value 53 instead. Why doesn't it print the same as the when the "castChar" is printed?
#include <stdio.h>
int main(void) {
int nr = 5;
char castChar = (char)nr;
char realChar = '5';
printf("The value is: %d\n", realChar);
}