HP-UX Reference (11i v3 07/02) - 3 Library Functions N-Z (vol 7)
p
printf(3S) printf(3S)
If an l (ell) qualifier is present, the argument must be a pointer to an array of type
wchar_t. Wide-characters from the array are converted to characters (each as if by
a call to the wcrtomb() function, with the conversion state described by an
mbstate_t object initialized to zero before the first wide-character is converted) up
to and including a terminating null wide-character. The resulting characters are writ-
ten up to (but not including) the terminating null character (byte).
If no precision is specified, the array must contain a null wide-character. If a preci-
sion is specified, no more than that many characters (bytes) are written (including
shift sequences, if any), and the array must contain a null wide-character if, to equal
the character sequence length given by the precision, the function would need to
access a wide-character one past the end of the array. In no case is a partial character
written.
S Same as ls.
p The value of a pointer to void arg is printed as a sequence of unsigned hexadecimal
numbers. The precision specifies the minimum number of digits to appear. If the
value being converted can be represented in fewer digits, it is expanded with leading
zeros. The default precision is 1. The result of converting a zero value with a preci-
sion of zero is a null string.
n A pointer to an integer arg is expected. This pointer is used to store the number of
bytes printed on the output stream so far by this call to the function. No argument is
converted.
% Print a %; no argument is converted. The entire conversion specification must be
%%.
In no case does a nonexistent or small field width cause truncation of a field; if the result of a conversion is
wider than the field width, the field is expanded to contain the conversion result.
The
a, e, f, and g conversions will print inf for infinity and
nan for both quiet and signaling NaN
values.
The A, E, F, and G conversions will print INF for infinity and
NAN for both quiet and signaling NaN values.
For
a and A conversions (on Itanium(R)-based systems), the value is correctly rounded to a hexadecimal
floating point number with the given precision.
The e, E, f, F, g, and G conversions on Itanium(R)-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 inter-
preted 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.
136 Hewlett-Packard Company − 4 − HP-UX 11i Version 3: February 2007