int a; scanf("%c",&a); printf("%d",a);
Please explain to the reason for this output?
That's what you get when you lie to scanf(). Assuming 4 byte integers, `a` looks like this (the question marks mean an indeterminate value): [?][?][?][?] Now when you pass the address of `a` into scanf() and say that it's a pointer to char, scanf() will do exactly what you asked … Read More
> Bit representation of 12 is 00000000 00000000 00000000 00001100. 12 has nothing to do with this. You may have typed 12, but scanf() read the numeric value of '1' and stored it in the first byte. Note also that depending on your system's endianness, the "first" byte may be … Read More
Edited by deceptikon