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:
-
- Normal characters,
These characters are output as they are;
- 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.