C examples for Language Basics:printf
By default, all output is right justified.
To left justify, place a minus sign directly after the %.
For example, %-10.2f left-justifies a floating -point number with two decimal places in a 10-character field.
The following program illustrates left justification:
#include <stdio.h> int main(void) { printf(".........................\n"); printf("right-justified: %8d\n", 100); printf(" left-justified: %-8d\n", 100); return 0;/* w w w. j av a2 s. com*/ }