+ 1
What's the output, printf("%c %c",87,599); ? Please Explain!
the question is about basic concepts in C language
5 Réponses
+ 5
The code playground have the answer.
0
%d expect a double floating point number, so output should be "87 599"
0
the question was wrong earlier.. sorry
0
It seems that characters are integers with a Batman suit, when integer i are converted to characters c, it returns the character from a builtin sequence of characters from the index i. (87 & 599)
0
The output is "W W". The reason why those different integers give the same character is that the size of a char is 1 byte while it is 4 bytes for int, so an int with non-zero bytes outside of the first byte ends up truncated when cast into a char. So 599, which is 0x00000257 as an int, becomes 0x57 (ie 87) as a char, which is the ascii code for 'W'.
https://code.sololearn.com/cWYn6mDK6eai/?ref=app