printf - Write formatted output

Synopsis

printf format [ argument ... ]

Description

You can use printf to format and display output on standard output. The syntax is similar to the ILE C printf() function. printf formats using the following conversion control string syntax:

%[flags][width].[precision]conversion

conversion specifies how the corresponding argument is displayed. You must specify one of the following conversion characters:

c
Unsigned character.
d
Signed decimal number.
e,E
Scientific notation.
f
Floating point number.
g,G
Scientific notation with significant digits.
i
Signed decimal number.
o
Unsigned octal number.
s
String.
u
Unsigned decimal number.
x
Unsigned hexadecimal number with digits 0123456789abcdef.
X
Unsigned hexadecimal number with digits 0123456789ABCDEF.

flags control how the argument is displayed in the following ways:

- (minus)
Left align argument within the field.
+ (plus)
Prefix all numbers with a + or -.
space
Prefix positive numbers with <space> and negative numbers with -.
0
Pad field width with leading zeros for d, e, E, f, g, or G.
#
Use an alternate output form depending on conversion character. For o, prefix octal numbers with "0". For x, prefix hexadecimal numbers with "0x". For X, prefix hexadecimal numbers with "0X". For e, E, f, g, or G, display decimal point. For g or G, display trailing zeros.

width is the minimum number of character positions displayed. Using an asterisk (*) character for the width means the value of the next argument is the field width.

The meaning of precision depends on the conversion character.

Options

None.

Operands

Each argument is converted and displayed as specified by the format.

Exit Status

Related information