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

p
printf(3S) printf(3S)
will print infinity and NaN as respectively,
INF and NAN
.
For
a and A conversions (for Itanium(R)-based system), the value is correctly rounded to a hexadecimal
floating point number with the given precision.
The e, E, f, g
, and G conversions on Itanium(R)-based system 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() )ora
negative value if an error was encountered.
snprintf() returns the number of bytes transmitted, excluding the null terminator, if maxsize is
sufficient to hold the formatted string. A negative value is returned if maxsiz is not sufficient to hold the
formatted string including the terminating null. The value of
errno is unspecified in this case.
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 file that exceeds the process’s file size limit or the max-
imum 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 signal,
and the process group of the process is orphaned.
HP-UX 11i Version 2: December 2007 Update − 4 − Hewlett-Packard Company 161