I am storing a char
in a long
variable and trying to print it using printf
.
long a = 'A';
printf("%c \n",a);
Considering default argument promotions the arguments get promoted to int
but as long
has higher rank than int
it should not get promoted (or actually demoted) to int
.
Now if it doesn't get promoted to int
, in the printf statement isn't there a type mismatch as we are trying to print a long
variable using %c
. According to C standard this behavior should be undefined but the compiler is perfectly printing A
as output without any error or warning. Why is it so ?
I am working on GCC codeblocks compiler.