HP-UX Reference (11i v2 04/09) - 3 Library Functions N-Z (vol 7)

p
printf(3S) printf(3S)
The A, E, and G
conversions will print INF for infinity and NAN for both quiet and signaling NaN values.
There will be a new
F conversion specifier that will be identical to the
f conversion specifier except that it
will print infinity and NaN as respectively,
INF and NAN.
For
a and A conversions (on Itanium-based systems), the value is correctly rounded to a hexadecimal
floating point number with the given precision.
The
e, E, f,
g, and G converions on Itanium-based systems round according to the specification in
ISO/IEC C99: if the number of significant decimal digits is at most 36, then the result is correctly
rounded.
Characters generated by
printf() and fprintf() are printed as if
putc() had been called (see
putc(3S)).
Application Usage
To use the
_INCLUDE__STDC_A1_SOURCE
functionality, the
_INCLUDE__STDC_A1_SOURCE
flag
must be passed as a compiler option or defined as a macro in source files.
After
printf() or fprintf() is applied to a stream, the stream becomes byte-oriented (see orienta-
tion(5)).
EXTERNAL INFLUENCES
Environment Variables
The
LC_CTYPE category affects the following features:
Plain characters within format strings are interpreted as single byte and/or multibyte characters.
Field width is given in terms of bytes. As characters are placed on the output stream, they are
interpreted as single byte or multibyte characters and the field width is decremented by the length
of the character.
Precision is given in terms of bytes. As characters are placed on the output stream, they are inter-
preted as single byte or multibyte characters and the precision is decremented by the length of the
character.
The return value is given in terms of bytes. As characters are placed on the output stream, they are
interpreted as single byte or multibyte characters and the byte count that makes up the return
value is incremented by the length of the character.
The
LC_NUMERIC category determines the radix character used to print floating-point numbers, and the
thousands’ grouping characters if the grouping flag
is on.
International Code Set Support
Single byte character code sets are supported. Multibyte character code sets are also supported as
described in the
LC_CTYPE category above.
RETURN VALUE
Each function returns the number of bytes transmitted (excluding the
\0 in the case of sprintf() or a
negative value if an output error was encountered.
ERRORS
printf(), and fprintf() fail if either the stream is unbuffered or stream’s buffer needed to be
flushed causing an underlying write() call to be invoked (see write(2)), and:
[EAGAIN] The
O_NONBLOCK flag is set for the file descriptor underlying stream and the process
would be delayed in the write operation.
[EBADF] The file descriptor underlying stream is not a valid file descriptor open for writing.
[EFBIG] An attempt was made to write to a le that exceeds the process’s file size limit or the
maximum file size (see ulimit(2)).
[EINTR] A signal was caught during the
write() system call.
[EIO] The process is in a background process group and is attempting to write to its controlling
terminal,
TOSTOP is set, the process is neither ignoring nor blocking the SIGTTOU sig-
nal, and the process group of the process is orphaned.
[ENOSPC] There was no free space remaining on the device containing the file.
HP-UX 11i Version 2: September 2004 4 Hewlett-Packard Company Section 3739