Created: 2023-01-11 11:14
Status: #concept
Subject: Programming
Tags: C stdio.h Character Format String

Minimum Field Width

It specifies the minimum number of characters to print/read.

If the value printed requires less characters than the minimum field width m, it will be right-justified (moved to the right) and spaces will pad the empty fields until it reaches m.

// - denotes whitespace

printf("%10.2f\n", 3.142f);
printf("%10.2f\n", 12.69f);

/*** OUTPUT ***/
------3.14
-----12.69

printf("%-10.2f\n", 3.142f);
printf("%-10.2f\n", 12.69f);

/*** OUTPUT ***/
3.14------
12.69-----

References