gpt4 book ai didi

对 %c 和 ASCII 代码感到困惑

转载 作者:太空宇宙 更新时间:2023-11-04 02:12:19 25 4
gpt4 key购买 nike

为什么 printf("%c ", 2293552); 打印 0

ASCII 值是从 0 到 127我知道这一定是一些循环的事情,但我想要一个明确的解释。谢谢

最佳答案

数字 2293552 对应于 0x22ff30。当 printf 将其解释为 ASCII 时,它会忽略包含 0x30 的最后八位以外的所有位,这是 '0' 的代码。

来自 C99 标准:

7.19.1.6.8 -- %c: If no l length modifier is present, the int argument is converted to an unsigned char, and the resulting character is written.

关于对 %c 和 ASCII 代码感到困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12516580/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com