它在 c11/c++ 中使用吗?:
printf("%2$*11$s",...)
它来自一个elf文件,这个文件使用printf()来操作,如mem[4]=mem[2]+mem[1]
.您可以从这里引用 https://ctftime.org/task/5042 (这是一个反向CTF问题)。就我而言,我知道 $ 用于指定哪个 var 的位置,但没有引用通知一个块可以有两个 $。
另外,除了位置之外,我在格式中找不到任何关于 $ 的函数。
所以,如果有人能告诉我这是有意义的,我将不胜感激。
最佳答案
n$
是 POSIX 中定义的扩展,用于选择要打印的参数。这称为参数字段。
printf format string - Wikipedia
其实这个问题是关于使用两个 n$
在一种格式说明符中。让我用小例子来检验......
#include <stdio.h>
int main(void) {
printf("%1$*3$s\n", "a", "b", 10, 20);
printf("%1$*4$s\n", "a", "b", 10, 20);
printf("%2$*3$s\n", "a", "b", 10, 20);
printf("%2$*4$s\n", "a", "b", 10, 20);
return 0;
}
Output : a
a
b
b
它看起来像 %n$*m$s
表示“使用 n
-th 参数指定的宽度打印 m
-th 参数”。最后s
有s
的意思在 %s
.
关于c++ - printf ("%2$*11$s", ...) 这个队形是什么意思,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68594461/