0

How we get 89 in the output ???

#include <stdio.h> int main() { int x, y; char text[20]; scanf("%2d %d %*f %5s", &x, &y, text); /* input: 6789 1.5 elephant */ printf("%d %d %s", x, y, text); /* output: 67 89 eleph */ return 0; }

4th Jul 2019, 12:32 PM
Shaishav Anand
Shaishav Anand - avatar
2 Respuestas
0
%2d reads only 2 digits, meaning it will be 67. The second one reads the next integer, which is 89, and so on
4th Jul 2019, 12:39 PM
Airree
Airree - avatar
0
Thanks
4th Jul 2019, 1:21 PM
Shaishav Anand
Shaishav Anand - avatar