gpt4 book ai didi

c - 将数字打印为十六进制数

转载 作者:太空宇宙 更新时间:2023-11-04 05:13:30 24 4
gpt4 key购买 nike

所以我有数字 12 如何以格式打印出来

0x0000000C // where there is always the 0x in the beginning and always 8 digits after to 
// represent the number

fprintf(outputFile, "%x", 12);

给我:

cc

但是我想要:

0x0000000C

最佳答案

需要前缀 0x 然后是大写 X 以获得大写 C 和 08 表示前缀为 0 以组成最多 8 个字符

fprintf(outputFile, "0x%08X", 12);

关于c - 将数字打印为十六进制数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20256426/

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