Ausam/doc/man/man3/printf.3

Find at most related files.
including files from this version of Unix.

.th PRINTF III 79/03/21
.sh NAME
printf \*- formatted print
.sh SYNOPSIS
.ft B
printf(format, arg1, ...);
.br
char *format;
.ft R
.sh DESCRIPTION
.it Printf
converts, formats, and prints its arguments after the first
under control of the first argument.
The first argument is a character string
which contains
two types of objects:
plain characters, which are simply copied to the
output stream,
and conversion specifications,
each of which causes conversion and printing
of the next successive argument to
.it printf.
.s3
Each conversion specification is introduced by
the character \fB%\fR.
Following the \fB%\fR, there may be
.s3
.lp +6 2
\*-	an optional minus sign ''\*-'' which specifies
.it "left adjustment"
of the converted argument
in the
indicated field;
.s3
.lp +6 2
\*-	an optional digit string specifying a
.it "field width;"
if the converted argument has fewer characters
than the field width
it will be blank-padded on the left (or right,
if the left-adjustment indicator has been
given) to make up the field width;
.s3
.lp +6 2
\*-	an optional period ''\fB.\fR'' which serves to
separate the field width from the
next digit string;
.s3
.lp +6 2
\*-	an optional digit string
.it "(precision)"
which specifies
the number of digits to appear after the
decimal point, for e- and f-conversion,
or the maximum number of characters
to be printed from a string;
.s3
.lp +6 2
.mc |
\*-	an optional ''\fB@\fR'' which specifies that the
next argument is actually a pointer to a data item
rather than a data item itself.
.mc
.s3
.lp +6 2
\*-	a character which indicates the type of
conversion to be applied.
.s3
.i0
The conversion characters
and their meanings are
.s3
.lp +6 3
d
.lp +6 3
o
.lp +6 3
x	The integer argument is converted to decimal, octal, or
hexadecimal notation respectively.
.s3
.lp +6 3
.mc |
D
.lp +6 3
O
.lp +6 3
X	The long argument is converted to decimal, octal, or
hexadecimal notation respectively.
.mc
.s3
.lp +6 3
f	The argument is converted to decimal notation
in the style ''[\fB\*-\fR]ddd.ddd''
where the number of d's after the decimal point
is equal to the precision specification
for the argument.
If the precision
is missing,
6 digits are given;
if the precision is explicitly 0, no digits and
no decimal point are printed.
The argument should be
.it float
or
.it double.
.s3
.lp +6 3
e	The argument is converted in the style
''[\fB\*-\fR]d\fB.\fRddd\fBe\fR\(+-dd''
where there is one digit before the decimal point and
the number after is equal to the
precision specification for the argument;
when the precision is missing,
6 digits are produced.
The argument should be a
.it float
or
.it double
quantity.
.s3
.lp +6 3
c	The argument character is printed.
.s3
.lp +6 3
s	The argument is taken to be a string (character pointer)
and characters from the string are printed until
a null character or until
the number of characters indicated by the precision
specification is reached;
however if the precision is 0 or missing
all characters up to a null are printed.
.s3
.lp +6 3
.mc |
u	The argument is taken to be an unsigned
integer which is converted to decimal
and printed (the result will be in the
range 0 to 65535).
.mc
.s3
.lp +6 3
.mc |
ld
.s3
.lp +6 3
lo
.lp +6 3
lx
.lp +6 3
l	Are equivalent to ''\fBD\fR'', ''\fBO\fR'',
\&''\fBX\fR'' and ''\fBu\fR'' respectively.
.mc
.s3
.lp +6 3
.mc |
t	Tabulates to the column number specified by the
field width field.
.mc
.s3
.lp +6 3
.mc |
r	The argument is taken to be a string (character pointer)
and shall be used instead of the format descriptor from this point.
.mc
.s3
.i0
If no recognizable character appears after the \fB%\fR,
that character is printed;
thus \fb%\fR may be printed by use of the
string \fB%%\fR.
In no case does a non-existent or small field width
cause truncation of a field;
padding takes place only if the specified field
width exceeds the actual width.
Characters generated by
.it printf
are printed by calling
.it putchar.
.sp
.mc |
The characters for padding when left- & right-justifying may be
specified independantly by assigning to the global bytes
.it prfa
and
.it prfb
respectively.
They are initially set to blanks.
.mc
.sh "SEE ALSO"
putchar (III)
.sh BUGS
Very wide fields (>128 characters) fail.