Printf () output format Control
1. Conversion specifiers
% A (% A) floating point number, hexadecimal number, and p-(P-) Notation (C99)
% C characters
% D signed decimal integer
% F floating point number (including float and doulbe)
% E (% E) floating point number index output [e-(E-) Note]
% G (% G) floating point number does not show meaningless zero "0"
% I signed decimal INTEGER (same as % d)
% U unsigned decimal integer
% O octal integer e.g. 0123
% X (% X) hexadecimal integer 0f (0F) e.g. 0x1234
% P pointer
% S string
% "%"
2. Flag
Left alignment: "-" e.g. "%-20 s"
Right alignment: "+" e.g. "% + 20 s"
Space: If the symbol is positive, space is displayed. If the symbol is negative, "-" e.g. "% 6.2f" is displayed"
#: It has no effect on Class c, s, d, and u. It adds the prefix o to class o in output; it also adds the prefix 0x to Class x in output;
The decimal point is given for Class e, g, and f when the result has decimal places.
3. Format String (Format)
[Flag] [minimum output width] [. Precision] [length] Type
"%-Md": Left alignment. If the m ratio is small, it is output as needed.
"% M. ns": output m-bit. Take the string (from left) n-bit, left fill space, when n> m or m is omitted, m = n
E.g. "% 7.2 s" input CHINA
Output "CH"
"% M. nf": Output floating point number. m indicates the width, and n indicates the right digit of the decimal point.
E.g. "% 3.1f" input 3852.99
3853.0 output
Length: h short integer, l long integer