Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
なぜprintf("%c ", 2293552);印刷するの0ですか?
printf("%c ", 2293552);
0
ASCII値は0から127です。これは循環的なものである必要があることはわかっていますが、明確な説明が必要です。ありがとうございました
番号2293552はに対応し0x22ff30ます。ASCIIとして解釈する場合、。のコードである、をprintf含む最後の8ビットを超えるすべてのビットを無視します。0x30'0'
2293552
0x22ff30
printf
0x30
'0'
C99標準から:
7.19.1.6.8- %c:l長さ修飾子が存在しない場合、int引数はに変換されunsigned char、結果の文字が書き込まれます。
%c
l
unsigned char
%c引数の下位バイトである。のみを使用している可能性があります2293552 & 255 = 48 = '0'。
2293552 & 255 = 48 = '0'