gpt4 book ai didi

C - %x 格式说明符

转载 作者:太空狗 更新时间:2023-10-29 16:17:20 24 4
gpt4 key购买 nike

我有一个小问题。我知道 %x 格式说明符可用于在格式字符串攻击中从堆栈中读取值。

我找到了以下代码:

%08x%08x%08x%08x

08 是什么意思?它到底在做什么?谢谢:)

最佳答案

segmentation :

  • 8表示要显示8位数字
  • 0,你想用 0 作为前缀,而不仅仅是空格
  • x 您要以小写十六进制打印。

快速示例(感谢 Grijesh Chauhan):

#include <stdio.h>
int main() {
int data = 29;
printf("%x\n", data); // just print data
printf("%0x\n", data); // just print data ('0' on its own has no effect)
printf("%8x\n", data); // print in 8 width and pad with blank spaces
printf("%08x\n", data); // print in 8 width and pad with 0's

return 0;
}

输出:

1d
1d
1d
0000001d

另见 http://www.cplusplus.com/reference/cstdio/printf/供引用。

关于C - %x 格式说明符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15108932/

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