string format definition

Source: Internet
Author: User
Tags format definition printf string format

string format definition

printf () function

The printf () function is a formatted output function that is generally used to output information in a prescribed format to a standard output device. This function is often used when writing programs. The call format for the printf () function is:

printf ("< format string >", < Parameter table >);

The format string consists of two parts: part of the normal character, and the characters are output as is; The other part is formatting the specified character, starting with "%" followed by one or more specified characters to determine the format of the output content.

Parameter table is a series of parameters that need to be output, the number must be the same as the number of output parameters described in the format string, the parameters are separated by "," and the order one by one corresponds, otherwise there will be unexpected errors.

form of format-string:%[flags][width]. [Precision] [{h|l|i|232|264}] Type

[Flags]----->{-, +, 0, #, blank}

Left align, sign, complement 0, output front plus space

[Width]-----Minimum number of characters for output >

[Precision]----->

{c,c: no impact.

{d,i,u,o,x,x: The minimum number of characters to output, if not enough, in front of the 0.

{f: Specify '. ' The number of characters to output, if precision is 0 or none, then no decimal.

{s,s: The maximum number of output characters, the default output to null end.

[{h|...| 264}]----> Specify the size of the following parameters.

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.