Source: printf parameter Summary
The format description string "is composed of a series of" format conversion specifiers ". The format conversion specifiers are described as follows:
% [+] [-] 0 m [. N] [output accuracy] <formal letter>
(1) form letters: Specify the output format, such as a table
D: decimal integer
I: decimal integer
X: hexadecimal integer
O: octal integer
U: Unsigned decimal integer
C: A single character;
S: String
E: exponential floating point number
F: Floating Point Number in decimal form
G: A shorter ratio of E and F
P: display the memory address of the Variable
N: It does not pass the formatting information to printf (), but enables printf () to put the total number of characters output by itself into the corresponding variable element
In the integer
%: Symbol % itself;
(2): If the output accuracy is D, X, O. U, the following two types of precision can be specified:
L: Long output precision
H: Short output precision
Int type precision by default
For example: long x = 123454578; printf ("% d", X );
If the formal letters are E, F, and G, the value of L is set to double instead of float;
(3): m [. N] specifies the output length. If the output is an instance, M indicates the total length of the output string, and N indicates the decimal part.
Character length, such as float x = 4.56; printf ("% 7.4f", X );
(4) 0: enter 0 for the unspecified empty position and 0 for the shareholding. the unused position is blank. This item is only available for output to the branches.
To specify, do not specify the string output. For example
Int x = 234;
Printf ("% 05d", x); // 00234
Printf ("% 5d", x); // *** 234
(5) [+] [-]: Specifies the output position. If + is specified or the default value is right-aligned, if-is left-aligned;