gpt4 book ai didi

c - 直接参数访问被忽略

转载 作者:行者123 更新时间:2023-11-30 18:12:58 24 4
gpt4 key购买 nike

所以我的代码行如下

printf("test @ 0x%1$08x = %2$d 0x%2$08x\n", &test_val, test_val);

但它不是打印变量而是打印变量

test @ 0x$08x = $d 0x$08x

它完全忽略百分比字符并且不打印任何变量。我找不到任何相关内容或任何可能发生这种情况的原因,希望有人可以提供帮助。

EDIT: I could not find a link but basically from my knowledge and from Hacking: The art of Exploitation the number after the percent character should be the parameter it uses so %n$d would use the nth parameter and print as a decimal. in this case %1$08x would print &test_val in hexadecimal and %2$d would print test_val as a decimal.

最佳答案

int c = 0;
int * p = &c;

printf("test@ 0x%d %d\n", &p, *p);

http://www.cplusplus.com/reference/cstdio/printf/查看此页面以了解哪些修饰符将有哪些类(class)。

(number) Minimum number of characters to be printed. If the value to be printed is shorter than this number, the result is padded with blank spaces. The value is not truncated even if the result is larger.

关于c - 直接参数访问被忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28665423/

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