C
x
10
1
2
3
int main(void) {
4
printf("%1$*3$s\n", "a", "b", 10, 20);
5
printf("%1$*4$s\n", "a", "b", 10, 20);
6
printf("%2$*3$s\n", "a", "b", 10, 20);
7
printf("%2$*4$s\n", "a", "b", 10, 20);
8
return 0;
9
}
10
$ gcc prog.c -Wall -Wextra -std=gnu11
Start
prog.c: In function 'main': prog.c:4:16: warning: format argument 2 unused before used argument 3 in '$'-style format [-Wformat=] 4 | printf("%1$*3$s\n", "a", "b", 10, 20); | ^~~~~~~~~~~ prog.c:4:16: warning: unused arguments in '$'-style format [-Wformat-extra-args] prog.c:5:16: warning: format argument 2 unused before used argument 4 in '$'-style format [-Wformat=] 5 | printf("%1$*4$s\n", "a", "b", 10, 20); | ^~~~~~~~~~~ prog.c:5:16: warning: format argument 3 unused before used argument 4 in '$'-style format [-Wformat=] prog.c:6:16: warning: format argument 1 unused before used argument 3 in '$'-style format [-Wformat=] 6 | printf("%2$*3$s\n", "a", "b", 10, 20); | ^~~~~~~~~~~ prog.c:6:16: warning: unused arguments in '$'-style format [-Wformat-extra-args] prog.c:7:16: warning: format argument 1 unused before used argument 4 in '$'-style format [-Wformat=] 7 | printf("%2$*4$s\n", "a", "b", 10, 20); | ^~~~~~~~~~~ prog.c:7:16: warning: format argument 3 unused before used argument 4 in '$'-style format [-Wformat=]
a a b b
0
Finish