Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What does "%5d" mean? C language uses different format characters for different types of data.
What does "%5d" mean? C language uses different format characters for different types of data.
%5d represents a decimal integer with an output width of 5 fields.

C language uses different format characters for different types of data. D format characters. Used to output decimal integers. %md, m is the width of the specified output field. %ld, output long integer data.

O format characters, the output integer is octal integer.

X format characters, output integers as hexadecimal numbers.

Extended data

U-format characters are used to output unsigned data, that is, unsigned numbers, which are output in decimal form.

C format characters, used to output a character.

S format characters, used to output a string.

F format characters, used to output real numbers (including single precision and double precision) and output them in decimal form.

E format characters, output real numbers in exponential form.

G format symbol, used to output real numbers. It automatically selects F format or E format according to the size of the numerical value (the selected output is the one with smaller width), and does not output meaningless zeros.

P format character, used for the output of variable address.

%[scanfset]:scanfset has two forms: 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.

Baidu Encyclopedia-Format Characters