What is the difference between %-8.5f and %8.5f in format specifiers in C | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What is the difference between %-8.5f and %8.5f in format specifiers in C

3rd May 2019, 7:28 AM
Honey Shree
3 Answers
+ 12
In %a.b a is minimum number of characters including whole part, point and decimal part b number of characters of decimal part If total number of characters are less than a, it fills with blank spaces at the left side of number With - sign it fills blank spaces at the right side of the number Example: printf("'%8.3f'",123.45); ' 123.450' printf("'%-8.3f'",123.45); '123.450 '
3rd May 2019, 8:10 AM
Javier Felipe Toribio
Javier Felipe Toribio - avatar
+ 6
%8.5f is right-aligned, %-8.5f is left-aligned
3rd May 2019, 8:06 AM
Anna
Anna - avatar
0
6
5th May 2019, 9:47 PM
مهدی گنجی
مهدی گنجی - avatar