scanf.3s (2010 09)

s
scanf(3S) scanf(3S)
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 char-
acters 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 certain conventions. A range of characters may be represented by the
construct first-last , enabling [0123456789] to be expressed [0-9]. Using this conven-
tion, first must be lexically less than or equal to last ; otherwise, the dash stands for
itself. The dash also stands for itself when it is the first or the last character in the
scanset. To include the right square bracket as an element of the scanset, it must
appear as the first character (possibly preceded by a circumflex) of the scanset, in
which case it will not be interpreted syntactically as the closing bracket. The
corresponding argument must point to a character array large enough to hold the data
field and the terminating
\0, which are added automatically. At least one character
must match for this conversion to succeed.
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 sequence and the terminating null wide-character, which will be added
automatically.
p A sequence of unsigned hexadecimal numbers is expected. This sequence may be pro-
duced by the p conversion character of printf(). The corresponding argument
shall be a pointer to a pointer to void into which the value represented by the hexa-
decimal sequence is stored. The behavior of this conversion is undefined for any input
item other than a value converted earlier during the same program execution.
The conversion characters
d, i, and n can be preceded by h, hh,
j, l, ll, t,orz to indicate that a
pointer to a
short int, signed char, intmax_t, long int, long long int
, ptrdiff_t,or
ssize_t rather than to an int is in the argument list. Similarly, the conversion characters u
, o, x,
and
X can be preceded by h, hh, j, l, ll, t
,orz to indicate that a pointer to a unsigned short int,
unsigned char, uintmax_t, unsigned long int, unsigned long long int, unsigned
ptrdiff_t,orsize_t rather than to an unsigned int is in the argument list. Finally, the conver-
sion characters e, E, f, F, g, and G can be preceded by l or L to indicate that a pointer to a double or
long double rather than to a float is in the argument list. The h, hh, j, l, L, ll, t,orz modifier is
ignored for other conversion characters.
The
scanf() functions terminate their conversions at EOF, at the end of the control string, or when an
input character conflicts with the control string. In the latter case, the offending character is left unread
in the input stream.
EXTERNAL INFLUENCES
Locale
The
LC_CTYPE category determines the interpretation of ordinary characters within format strings as
single and/or multi-byte characters. Field width is given in terms of bytes. Characters received from the
input stream are interpreted as single- or multi-byte characters as determined by the LC_TYPE category
and the field width is decremented by the length of the character.
The
LC_NUMERIC category determines the radix character expected within floating-point numbers.
HP-UX 11i Version 3: September 2010 3 Hewlett-Packard Company 3