Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Introduction to format characters
Introduction to format characters
Printf function format characters:

The following are commonly used format characters:

Characters in (1)d format. Used to output decimal integers. There are the following usages:

1, %d, output according to the actual length of integer data.

2.%md, where m is the width of the specified output field.

3.%ld, output long shaping data.

(2)o format characters, which output integers in the form of octal integers.

(3)x format characters, which output integers in the form of hexadecimal numbers.

(4) The U-format symbol is used to output unsigned data, that is, unsigned numbers, which are output in decimal form.

(5)c format characters, which are used to output a character.

(6) Characters in S format are used to output a string.

(7)f format symbol, which is used to output real numbers (including single precision and double precision) and output in decimal form.

(8)e-format symbols, which output real numbers in exponential form.

(9)g format symbol, which is used to output real numbers. According to the size of the numerical value, F format or E format is automatically selected (the selected output is the one with smaller width), and meaningless zeros are not output.

(10)%[ scanning offset]:

There are two forms of scanfset: one is a scanset that starts with a non-character, which means that all characters in the scanfset will be matched when reading the string, and the input will end when encountering a non-scanfset character; The other form is a scanfset that starts with a ""character, which means that when reading a string, all characters that do not appear in the scanfset will be matched, and the input of characters in the scanfset will end.