First, the control of the input format
Format characters in the scanf function:
(1) D,i: Used to enter signed decimal
(2) U: used to enter unsigned decimal integers
(3) O: Used to enter unsigned octal integers
(4) X,x: Used to enter unsigned hexadecimal integers (same size for writing)
(5) C: Used to enter a single symbol
(6) S: Used to enter a string, send the string to a character array, start with a non-whitespace character at the time of the input, with the first blank
The character ends. The string ends with an end to the sign ' \ s ' as its last character
(7) F: Used to enter real numbers, which can be entered in decimal or exponential form
(8) E,e,g,g: Same as F, E and f,g can be replaced with each other (case is the same)
Additional characters in the scanf function:
(1) L: For input of Long Integer data (available%ld,%lo,%lx,%lu) and double type data (with%LF or%le)
(2) H: For input of short-integer data (available%hd,%ho,%hx)
(3) Domain wide: Specifies the width of the input data (number of columns), the domain should be a positive integer
(4) *: Indicates that this input is not assigned to the corresponding variable after reading
Second, the output format control
Format characters in the printf function
(1) D,i: Output integer in signed decimal form (positive not output symbol)
(2) O: Output an integer in octal unsigned form (not output leader 0)
(3) X,x: Output an integer in hexadecimal unsigned form (not output leader 0).
Output hexadecimal numbers with x output in lowercase a~f, with an uppercase output when x is used
(4) U: output integer in unsigned decimal form
(5) C: Output as a character, output only one character
(6) S: Output string
(7) F: Output single, double precision numbers in decimal form, implicitly output 6 decimal places
(8) E,e: Output a real number as an exponent, with an e exponent expressed in E (such as 1.2e+02), with an e exponent expressed in E (e.g.
1.2E+02)
(9) G,g: Choose a format with a shorter output width in the%f or%e format, and do not output meaningless 0. When using g, if the exponential form
Output, the exponent is indicated in uppercase
Additional characters in the printf function
(1) L: For long integers, can be added in front of the format symbol D, o, x, u
(2) m (representing a positive integer): Minimum data width
(3) n (representing a positive integer): For the real number, the output n decimal place;
(4)-: The number or character of the output is left-leaning within the domain
Control of input and output formats in C language