Field-width : printf Field width « printf scanf « C Tutorial






Field-width sets the least number of columns for output.

#include <stdio.h>
main()
{
    int i = 9;
    printf(">%4d<",i);
}
>   9<

If the value is more than the specified column, field-width is ignored.

#include <stdio.h>
main()
{
    int i = 999999;
    printf(">%4d<",i);
}
>999999<








4.15.printf Field width
4.15.1.Field-width