Flags : printf Justify « printf scanf « C Tutorial






Flag characters are used to give directives for the output.

You can use multiple flag characters in any order.

- Indicates that output is left justified.

#include <stdio.h>

main()
{
    printf("%-10.4d\n", 25);
    printf("%10.4d\n", 25);
}
0025
           0025








4.16.printf Justify
4.16.1.Flags
4.16.2.Right justifying and left justifying values