Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What does %-7.2d mean in C language?
What does %-7.2d mean in C language?
It means that the floating-point type occupies seven widths, and two decimal places are reserved, and the decimal point is also considered as the width.

.2 is reserved for two decimal places, and 7 means the width is 7.

The code example is as follows:

# include & ltstdio.h & gt

int main()

{

Floating point number a = 5.1523;

printf("%7.2f\n ",a);

Returns 0;

}

Extended data:

There are no input and output statements in standard C language, but input and output functions in standard library can be called to realize input and output. The basic syntax structure of output format control is as follows:

Printf (format control, output item 1, output item 2, ...)

Where the format control is in the form of a string. The format usually includes: "%",followed by the format descriptor.

Character output

When characters are to be output to an output device (display screen, printer, etc.). ), which can be controlled by C format descriptors. The code shown below is the output character ch (a):

char ch = ' a

printf("Character: %c \n ",ch);