", )"."/> ", )".">

Home  >  Article  >  Backend Development  >  Detailed explanation of printf usage

Detailed explanation of printf usage

藏色散人
藏色散人Original
2020-03-03 09:39:1014834browse

Detailed explanation of printf usage

Detailed explanation of printf usage

The function of the printf command is to format the output function, which is generally used to output to the standard output device. Output information in a specified format. The calling format of the printf() function is: printf ("43011ca727a0874b13f23041c145d8f3", 31da099783b48fa279f5f90bfa120f6e). printf() is a C language standard library function, defined in stdio.h. In addition to letters, numbers, spaces, and some numeric symbols, the output string can also use some escape characters to express special meanings.

Recommended: "C Language Tutorial"

printf function definition

Function declaration

int printf(char *format...);

call Format

printf("<格式化字符串>", <参量表>);

The format string contains three objects, namely:

(1) String constant;

(2) Format control string;

(3) Escape characters.

String constants are output as they are and serve as prompts in the display. Each output item is given in the output table column, and it is required that the format control string and each output item should correspond one-to-one in quantity and type. The format control string is a string starting with %, followed by various format control characters to describe the type, width, precision, etc. 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 an embedded format tag, which can be replaced by the value specified in subsequent additional parameters and formatted as required.

The format control string format of printf is composed as follows:

%[flags][width][.prec][length]type

That is: %[flag][minimum width][.precision][type length] type

More For programming-related content, please pay attention to the Introduction to Programming column on the php Chinese website!

The above is the detailed content of Detailed explanation of printf usage. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn