1 #include
2
3 int main()
4 {
5 int i = 5;
? 6 printf("%d %d\n",i); / * wrong */
7 return 0;
8 }
trp@DESKTOP-ET7Q9JO:~$ gcc -o t1 t1.c
t1.c: In function ‘main’:
t1.c:6:17: warning: format ‘%d’ expects a matching ‘int’ argument [-Wformat=]
6 | printf("%d %d\n",i);
| ~^
| |
| int
1 #include
2
3 int main()
4 {
5 int i = 5, j = 6;
? 6 printf("%d\n",i, j);
7 return 0;
8 }
trp@DESKTOP-ET7Q9JO:~$ gcc -o t2 t2.c
t2.c: In function ‘main’:
t2.c:6:12: warning: too many arguments for format [-Wformat-extra-args]
6 | printf("%d\n",i, j);
1 #include
2
3 int main()
4 {
5 int i = 5;
6 float x = 6.0;
? 7 printf("%f %d\n",i, x);
8 return 0;
9 }
trp@DESKTOP-ET7Q9JO:~$ gcc -o t3 t3.c
t3.c: In function ‘main’:
t3.c:7:14: warning: format ‘%f’ expects argument of type ‘double’, but argument 2 has type ‘int’ [-Wformat=]
7 | printf("%f %d\n",i, x);
| ~^ ~
| | |
| double int
| %d
t3.c:7:17: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘double’ [-Wformat=]
7 | printf("%f %d\n",i, x);
| ~^ ~
| | |
| int double
| %f