Ansi c -- format the output

Source: Internet
Author: User
Document directory
  • [Prototype]
  • [Description]
  • [Format Rules]
[Prototype]

Printf ("<Format String>

",<Parameter table>

);

 

Int printf
(Const char * format ,...);
Int fprintf
(File * stream, const char * format ,...);
Int sprintf
(Char * STR, const char * format ,...);
Int snprintf
(Char * STR, size_t size, const char * format ,...);

Vprintf
(Const char * format, va_list AP );
Vfprintf
(File * stream, const char * format, va_list AP );
Int vsprintf
(Char * STR, const char * format, va_list AP );

[Description]

Install the format-matching syntax and add a character after "%" in the template string to format the string.

 

What is formatting?
Output?

What is formatting?
When ansic is used to output a string, it is rare to simply output a constant string. In more cases, it must be processed before the output and output in a specific format, this is what we call formatting.
.

[Format Rules]

The following describes the general call formats for formatting output functions:

 

Printf ("<Format String>

",<Parameter table>

);

  • Format a string
    Includes two parts:
  1.  
    1. Normal characters,
      These characters are output as they are;
    2. With formatted characters
      , Also knownPlaceholder
      , Starting with "%", followed by one or more specified characters, used to determine the output content format.
  • Parameter table
    Is a series of parameters to be output. The number of parameters must be the same as the number of output parameters described in the format string. The parameters are separated by commas (,) and the order is one to one, otherwise, unexpected errors may occur.

 

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.