It's an extension to the language added by POSIX (C11-compliant behaviour should be as described in an answer by @chux). Notation %2$d
means the same as %d
(output signed integer), except it formats the parameter with given 1-based number (in your case it's a second parameter, b
).
So, when you run the following code:
#include <stdio.h>
int main() {
int a = 3, b = 2;
printf("%2$d %1$d", a, b);
return 0;
}
you'll get 2 3
in standard output.
More info can be found on printf man pages.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…