6Where the specifier character at the end is the most significant component, since it defines the type and the interpretation of its corresponding argument:
7specifier Output Example
8d or i Signed decimal integer 392
9u Unsigned decimal integer 7235
10o Unsigned octal 610
11x Unsigned hexadecimal integer 7fa
12X Unsigned hexadecimal integer (uppercase) 7FA
13f Decimal floating point 392.65
14e Scientific notation (mantissa/exponent), lowercase 3.9265e+2
15E Scientific notation (mantissa/exponent), uppercase 3.9265E+2
16g Use the shortest representation: %e or %f 392.65
17G Use the shortest representation: %E or %f 392.65
18a Hexadecimal floating point, lowercase -0xc.90fep-2
19A Hexadecimal floating point, uppercase -0XC.90FEP-2
20c Character a
21s String of characters sample
22p Pointer address b8000000
23% A % followed by another % character will write a single % to the stream.
24
25The format specifier can also contain sub-specifiers: flags, width, .precision and modifiers (in that order), which are optional and follow these specifications:
26
27flags description
28- Left-justify within the given field width; Right justification is the default (see width sub-specifier).
29+ Forces to preceed the result with a plus or minus sign (+ or -) even for positive numbers. By default, only negative numbers are preceded with a - sign.
30(space) If no sign is going to be written, a blank space is inserted before the value.
31# Used with o, x or X specifiers the value is preceeded with 0, 0x or 0X respectively for values different than zero.
32 Used with a, A, e, E, f, F, g or G it forces the written output to contain a decimal point even if no more digits follow. By default, if no digits follow, no decimal point is written.
330 Left-pads the number with zeroes (0) instead of spaces when padding is specified (see width sub-specifier).
34
35width description
36(number) Minimum number of characters to be printed. If the value to be printed is shorter than this number, the result is padded with blank spaces. The value is not truncated even if the result is larger.
37
38.precision description
39.number For integer specifiers (d, i, o, u, x, X): precision specifies the minimum number of digits to be written. If the value to be written is shorter than this number, the result is padded with leading zeros. The value is not truncated even if the result is longer. A precision of 0 means that no character is written for the value 0.
40For a, A, e, E, f and F specifiers: this is the number of digits to be printed after the decimal point (by default, this is 6).
41For g and G specifiers: This is the maximum number of significant digits to be printed.
42For s: this is the maximum number of characters to be printed. By default all characters are printed until the ending null character is encountered.
43If the period is specified without an explicit value for precision, 0 is assumed.