Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Output of int data in c language
Output of int data in c language
%5.2 5 means the width is at least 5 digits, which is not enough to be filled with spaces. If it is greater than 5 digits, output 2 according to the actual width to represent the maximum digits.

The following content is copied and I hope it will help you.

int printf(const char *format,[argument]);

Format parameter output format, defined as:

% [logo] [width] [. PERC][F | N | h | l] type

Specify the data output mode as follows:

1.type has the following meanings:

integer

The parameter of %d integer will be converted to a signed decimal number.

The parameter of %u integer will be converted to unsigned decimal number.

The parameter of integer %o will be converted to unsigned octal number.

The parameter of %x integer will be converted to unsigned hexadecimal number and represented by lowercase abcdef.

Parameters of %X integer will be converted to unsigned hexadecimal numbers, and floating-point numbers will be represented by uppercase ABCDEF.

Parameters of type %f double will be converted to decimal numbers and rounded to six decimal places.

Parameters of type %e double are printed in exponential form, with one digit before the decimal point and six digits after the decimal point, and the exponential part is represented by lowercase e.

The function of %E is the same as that of %e, the only difference is that the exponent part will be represented by the capital letter e.

Parameters of type %g double will be automatically printed in the format of %f or %e, and the standard is determined according to the numerical value to be printed and the set number of significant digits.

%G has the same function as %g, the only difference is that %E format will be selected when printing in exponential form.

Characters and strings

The parameters of %c integer will be converted to unsigned characters and printed.

%s The parameter pointing to the string will be output word for word until a null character appears.

%p If the parameter is a "void *" pointer, it will be displayed in hexadecimal format, with the near pointer as XXXX and the far pointer as XXXX:YYYY.

%% shows the percent sign itself.

%n The parameter of the connection should be a pointer, which holds the number of characters written.

2.flags specifies the output format and has the following values and meanings:

There is no right alignment, and the left side is filled with 0 and spaces.

-left-aligned and right-filled with spaces

+Add the symbol+or-before the number.

Spaces only show negative symbols.

# When type=c, s, d, i, u, it has no effect.

Type=o, x, x, and add' 0', "0x" and "0x" before the values respectively.

When type=e, e, f, always use the decimal point.

When type=g, g, except the value 0, the decimal point is always displayed.

3.width is used to control the width of the displayed value, and its value and significance are as follows.

N(n= 1, 2, 3 ...) is at least n bits wide, which is not enough to be filled with spaces.

The width of 0n(n= 1, 2,3 ...) is at least n bits, which is not enough to fill the left side with 0 *.

In the format list, the next parameter is still the width.

IV .. prec is used to control the number of digits after the decimal point, and its values and meanings are as follows:

Not displayed at the default precision.

0 when type=d, I, o, u, x, it has no effect.

When type=e, e, f, the decimal point is not displayed.

Maximum number of digits when N(n= 1, 2, 3...)type = e, e, f.

Type= Other, indicating the maximum width of the display. *

In the format list, the next parameter is still the width.

5.F|N|h|l indicates whether the pointer is a far pointer or whether the integer is a long integer.

F far pointer

Near pointer

H short integer or single precision floating point number

L long integer or double-precision floating-point number