scanf.3s (2010 09)

s
scanf(3S) scanf(3S)
d A decimal integer is expected; the corresponding argument should be an integer
pointer.
u An unsigned decimal integer is expected; the corresponding argument should be an
unsigned integer pointer.
o An octal integer is expected; the corresponding argument should be an unsigned
integer pointer.
x, X A hexadecimal integer is expected; the corresponding argument should be an unsigned
integer pointer. The x and X conversion characters are equivalent.
i An integer is expected; the corresponding argument should be an integer pointer. The
value of the next input item, interpreted according to C conventions, will be stored; a
leading 0 implies octal, a leading 0x
implies hexadecimal; otherwise, decimal is
assumed.
hL An extended type is expected; the corresponding argument should be an
extended
pointer which is the 80-bit IEEE-754 double-extended type in the Itanium architec-
ture; should be used with the floating-point specifiers
a, A, e, E, f, F, g, and
G.
n Cause the total number of bytes (including white space) scanned since the function call
to be stored; the corresponding argument should be an integer pointer. No input is
consumed. The function return value does not include
%n assignments in the count of
successfully matched and assigned input items.
a,A,e,E,f,F,g,G
A floating-point number is expected; the next field is converted accordingly and stored
through the corresponding argument, which should be a pointer to a float . The input
format for floating-point numbers is an optionally signed string of digits, possibly con-
taining a radix character, followed by an optional exponent field consisting of an
E or
an e, followed by an optional +, -, or space, followed by an integer. For Itanium(R)-
based systems only, hexadecimal floating-point input also is accepted: the format is an
optionally signed string of hexadecimal digits, possibly containing a radix character,
followed by an optional binary exponent field (indicating the power of two by which the
significant part is to be scaled) consisting of a P or a p, followed by an optional
+, -,or
space, followed by a decimal integer. The conversion characters
A, E, F, and G
behave
the same as, respectively,
a, e, f, and g. The a, A, e, E, f, F, g, and G conversions
will convert the string
inf (case insensitive) or the string infinity (case insensitive)
to the appropriate floating point infinity value (single, double, or quadruple precision,
as specified by the conversion precision modifier). The a, A, e
, E, f, F, g, and G
conversions will convert the string nan (case insensitive) to the appropriate floating
point NaN value (single, double, or quadruple precision, as specified by the conversion
precision modifier).
c A character is expected; the corresponding argument should be a character pointer.
The normal skip-over-white-space is suppressed in this case; to read the next non-
space character, use %1s. If a field width is given, the corresponding argument refers
to a character array; the indicated number of characters is read.
If an
l (ell) qualifier is present, the input is a sequence of characters that begins in the
initial shift state. Each character in the sequence is converted to a wide-character as if
by a call to the mbrtowc() function, with the conversion state described by an
mbstate_t object initialized to zero before the first character is converted. The
corresponding argument must be a pointer to an array of wchar_t large enough to
accept the resulting sequence of wide-characters. No null wide-character is added.
The normal skip-over-white-space is suppressed in this case; to read the next non-
space character, use %1S. If a field width is given, the corresponding argument refers
to a wide character array; the indicated number of characters is read and converted.
C Same as lc.
s A character string is expected; the corresponding argument should be a character
pointer pointing to an array of characters large enough to accept the string and a ter-
minating \0, which is added automatically. The input field is terminated by a white-
space character. scanf() cannot read a null string.
2 Hewlett-Packard Company 2 HP-UX 11i Version 3: September 2010