The parameters after p>
printf include "format control string" and the list of output variables "format control string", which consists of format control characters and ordinary characters. Where the former begins with% and a special character is added. For example, %d is an output integer and %c is an output character. Ordinary characters are the content output as it is.
The list of output variables is the output variables, and its number should be relative to the control characters. For example, there are int a=3, b=4, and then Pritf ("A =% d, b=%d", a, b).
the output result is a=3 and b=4. Take abc in printf("abc ") as the format to control the ordinary characters in the string, and output it as it is. Print ("%d", i) is the value of the output variable i by shaping.
the function of p>printf command is print format function, which is generally used to output information to standard output devices in a specified format. The calling format of the printf () function is: printf ("<; Format string > " , < Parameter table > )。
printf () is a standard library function of C language, which is defined in stdio.h The output string can use not only letters, numbers, spaces and some number symbols, but also some escape characters to express special meanings.
extended data:
printf function definition:
function declaration:
int printf (char * format ...);
call format:
printf ("<; Format string > " , < Parameter table > );
a formatted string contains three objects, namely:
(1) a string constant;
(2) format control strings;
(3) escape characters.
the string constant is output as it is, which plays a prompt role in the display. Each output item is given in the output table column, which requires that the format control string and each output item should correspond to each other in number and type. Among them, the format control string is a string starting with%, followed by various format control symbols to explain the type, width and precision of the output data.
format control string format:
format-is a string containing the text to be written to the standard output stdout. It can contain embedded format tags, which can be replaced by values specified in subsequent additional parameters and formatted as required.
the format control string format of p>printf consists of the following:
% [flags] [width] [.prec] [length] type.
namely:% [mark] [minimum width] [.precision] [type length] type.
Baidu encyclopedia -printf