printf Format Specifiers
Go Up to printf, wprintf
Print format specifiers have the following form:
% [flags] [width] [.prec] [F|N|h|l|L] type_char
Each format specifier begins with the percent character (%).
Optional Format String Components
These are the general aspects of output formatting controlled by the optional characters, specifiers, and modifiers in the format string:
Component | Optional/Required | What It Is/Does | |||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
[flags] |
(Optional) |
They can appear in any order and combination.
Note: Plus (
+ ) takes precedence over blank () if both are given. | |||||||||||||||||||||||||||||||||||||||
[width] |
(Optional) |
The width specifier sets the minimum field width for an output value. Width is specified in one of two ways:
If you use an asterisk for the width specifier, the next argument in the call (which must be an int) specifies the minimum output field width. Nonexistent or small field widths do not cause truncation of a field. If the result of a conversion is wider than the field width, the field is expanded to contain the conversion result. How output width is affected n = At least n characters are printed. If the output value has less than n characters, the output is padded with blanks (right-padded if the flag is given, left-padded otherwise). 0n = At least n characters are printed. If the output value has less than n characters, it is filled on the left with zeros. '*' = The argument list supplies the width specifier, which must precede the actual argument being formatted. |
|||||||||||||||||||||||||||||||||||||||
[prec] |
(Optional) |
Precision specifier. Maximum number of characters to print; for integers, minimum number of digits to print. | |||||||||||||||||||||||||||||||||||||||
[F|N|h|l|L] |
(Optional) |
These modifiers determine how printf functions interpret the next input argument, arg[f].
These modifiers affect how all the printf functions interpret the data type of the corresponding input argument arg.
Both | |||||||||||||||||||||||||||||||||||||||
type_char |
(Required) |
%lld
format, RAD Studio recommends using it instead of using %Ld
.