+ 1
Input format
int x, y; char text[20]; scanf("%2d %d %*f %5s", &x, &y, text); /* input: 1234 5.7 elephant */ printf("%d %d %s", x, y, text); /* output: 12 34 eleph */ Can anyone explain the output
1 Resposta
0
%2d limits the number of digit extracted and assigned to <x> to only 2 digits max. Thus for integer input 1234, only 12 (two digits) is extracted and be assigned to <x>.
%5s does the same thing for variable <text>. It sets a max limit of 5 characters to be extracted and assigned to <text>. 5 characters of "elephant" -> "eleph".