C printf () function conversion specifier

Source: Internet
Author: User

1. Conversion specifier

Conversion instructions                                                   Output                                                                 
%a Floating-point numbers, hexadecimal numbers, and p-counting methods
%A Floating-point numbers, hexadecimal numbers, and p-counting methods
%c A character
%d Signed Decimal
%e Floating-point number, E-counting method
%E Floating-point number, E-counting method
%f Floating-point, decimal-counting method
%g Automatically select the%f or%e.%e format when the exponent is less than-4 or greater than or equal to the precision based on the value
%G Automatically select the%f or%e.%e format when the exponent is less than-4 or greater than or equal to the precision based on the value
%i Signed decimal with D
%o Unsigned 8 binary
%p Pointer
%s String
%u unsigned decimal
%x Use a hexadecimal 0f unsigned integer
%x Use a hexadecimal 0F unsigned integer
%% Print a percent semicolon

2. Conversion Descriptor Modifiers

Modifier Significance
Sign Five flags:-, +, space, #和0
Digit (s) Field width Minimum value e.%4d
. Digit (s) Precision. Corresponds to%e,%e, and%f conversions, which are the digits of the number that will be printed to the right of the decimal point.
H Used with integer conversions to represent an integer type of short
hh Used with integer conversion specifiers to represent a singed char or unsigned char
L Used with integer conversions to represent an integer type of long
L Used with floating-point type conversions to indicate a float type of type long
T Used in conjunction with integer conversions to represent a ptrdiff_t
Z Used with integer conversions to represent a size_t (sizeof return type) E.%ZD

3. Logo

/tr>
Span style= "FONT-SIZE:14PX;" > - Project left-aligned E. "%-20s"
+ displays the sign of the value E. "+6.2f"
(space) span> signed with a leading space; if negative, displays a minus sign
Span style= "FONT-SIZE:14PX;" > # E.% #o
0 For all number formats, the field width is filled with leading zeros instead of spaces, or if the specified precision is omitted.

C printf () function conversion specifier

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.