What is the use of coefficients before %f and %d | Sololearn: Learn to code for FREE!
0

What is the use of coefficients before %f and %d

What is the use of placing numbers like 2 and symbols like * in scanf("%2d%*f",&a,&b)

14th Jul 2019, 5:22 PM
S.S.A.V Panchajanya
6 ответов
+ 3
%2d means that it will take either one or two digit number. If you enter more than two digits number, it will skip after two digits. If you input 24568, it will skip last three digits and will accept only first two digits i.e 24. %*f means that the input of this variable will be skipped Refer to this section : https://www.sololearn.com/learn/C/2914/
14th Jul 2019, 5:48 PM
blACk sh4d0w
blACk sh4d0w - avatar
0
If you have %2d it means it will print integer number with the width at least 2 wide, %.*f will printout float number with the width of 6 numbers after the comma
14th Jul 2019, 5:43 PM
Dejan Francuz🥇
Dejan Francuz🥇 - avatar
0
Is it ok when we use only%f or %d in the place is %2d or %*f
14th Jul 2019, 5:45 PM
S.S.A.V Panchajanya
0
If you use only %*f in that case you won't get any output
14th Jul 2019, 5:46 PM
Dejan Francuz🥇
Dejan Francuz🥇 - avatar
0
Thank you
14th Jul 2019, 5:51 PM
S.S.A.V Panchajanya
0
Any one more precise about %*f in the following int a,b; char c[10]; scanf("%2d %d %*f %5s",&a,&b,&c); printf,("\n %d%d%s",a,b,c); i removed %*f in scanf and gave input 12 231456 tri it is showing 12 231 456 can you explain why
14th Jul 2019, 5:59 PM
S.S.A.V Panchajanya