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

s
scanf(3S) scanf(3S)
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 architecture;
should be used with the floating-point specifiers
a, A, e, E, 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 con-
sumed. The function return value does not include
%n assignments in the count of suc-
cessfully matched and assigned input items.
a,A,e,E,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 for-
mat for floating-point numbers is an optionally signed string of digits, possibly containing
a radix character, followed by an optional exponent field consisting of an
E or an e, fol-
lowed by an optional
+, -, or space, followed by an integer. For Itanium(R)-based sys-
tems 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 significand 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, and G behave the same as, respec-
tively, a, e, and g. The a, A, e, E
, 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, g, and
G conversions will convert the string nan
(case insensitive) to the appropriate floating point NaN value (single, double, or quadru-
ple 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 char-
acter, use %1s. If a field width is given, the corresponding argument refers to a charac-
ter 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 char-
acter, 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 terminating
\0, which is added automatically. The input field is terminated by a white-space charac-
ter. scanf() cannot read a null string.
If an l (ell) qualifier is present, the input is a sequence of characters that begins in the
initial shift state. Each character 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 sequence and the
terminating null wide-character, which will be added automatically. The input field is
terminated by a white-space character. scanf() cannot read a null string.
S Same as ls.
[ Indicates string data and the normal skip-over-leading-white-space is suppressed. The
left bracket is followed by a set of characters, called the scanset, and a right bracket; the
input field is the maximal sequence of input characters consisting entirely of characters
in the scanset. The circumflex (ˆ), when it appears as the first character in the scanset,
serves as a complement operator and redefines the scanset as the set of all characters not
contained in the remainder of the scanset string. Construction of the scanset follows cer-
tain conventions. A range of characters may be represented by the construct first-last,
enabling [0123456789]to be expressed [0-9]. Using this convention, first must be lexically
HP-UX 11i Version 2: December 2007 Update − 2 − Hewlett-Packard Company 377