The information in this table is based on the assumption that no flag characters, width specifiers, precision specifiers, or input-size modifiers were included in the format specifier.
Note. Certain accompany some of these format specifiers.
Type Char
|
Expected Input
|
Format of output
|
Numerics
|
|
|
d
|
Integer
|
signedinteger
|
i
|
Integer
|
signed decimal integer
|
o
|
Integer
|
unsigned octal integer
|
u
|
Integer
|
unsigned decimal integer
|
x
|
Integer
|
unsigned hexadecimal int (with a, b, c, d, e, f).
|
X
|
Integer
|
unsigned hexadecimal int (with A, B, C, D, E, F).
|
f
|
Floating-point
|
signed value of the form [-]dddd.dddd.
|
e
|
Floating-point
|
signed value of the form [-]d.dddd or [+/-]ddd
|
g
|
Floating-point
|
signed value in either ef form, based on given value and precision. Trailing zeros and the decimal point are printed if necessary.
|
E
|
Floating-point
|
Same as e; with E for exponent.
|
G
|
Floating-point
|
Same as g; with E for exponent if e format used.
|
Characters
|
|
|
c
|
Character
|
Single character.
|
s
|
String pointer
|
|
%
|
None
|
Prints the % character.
|
Infinite floating-point numbers are printed as +INF and -INF.
An IEEE Not-A-Number is printed as +NAN or -NAN.
|