Guardian Native C Library Calls Reference Manual (G06.28+, H06.05+)

Guardian Native C Library Calls (s) scanf(3)
s Accepts a string of characters. The input eld ends with a white-space
character. If width is given, the corresponding pointer parameter refers
to a character array and the indicated number of type char values are
read. A string of type char values is written to the array. The array must
be large enough to contain the output string with a terminating null byte
appended.
S Accepts a string of characters. The input eld ends with a white-space
character. If width is given, the behavior of the conversion is undened.
The corresponding pointer parameter should be a pointer to an array of
type wchar_t. A string of type wchar_t is written to the array. The
array must be large enough to contain the output string with a terminat-
ing null wide character appended.
u Accepts an unsigned decimal integer; the corresponding
pointer parame-
ter should be an unsigned integer pointer.
x Accepts a hexadecimal integer; the corresponding pointer parameter
should be an integer pointer.
[scanset] Accepts as input the characters included in scanset. scanset explicitly
denes the characters that are accepted in the input stream to be those
enclosed within [](square brackets). The corresponding pointer param-
eter should be an array of type char. The leading white space that is
normally skipped over is suppressed. A scanset in the form [ˆscanset] is
an exclusive scanset: the ˆ (circumex) is a complement operator and the
characters in the following scanset are not accepted as input. Conven-
tions used in the construction of scanset are:
You can represent a range of characters by the construct
first-last. Thus, you can express [0123456789] as [0-9]. The
first value must be lexically less than or equal to the last value,
or else the - (dash) stands for itself. The - (dash) also stands for
itself whenever it is the rst or last character in scanset.
You can include the ] (right bracket) as an element of scanset if
it is the rst character of scanset. In this case, it is not inter-
preted as the bracket that closes scanset.Ifscanset is an
exclusive scanset, the ] is preceded by the ˆ (circumex) to make
the ] an element of scanset. The corresponding pointer parame-
ter must point to a character array large enough to contain the
output string with a terminating 0 (zero) appended. The 0 (zero)
is added automatically.
The results from the conversion are placed in *pointer unless you specify assignment suppres-
sion with an * (asterisk). Assignment suppression provides a way to describe an input eld that
is to be skipped. The input eld is a string of non-white-space characters. It extends to the next
inappropriate character or until width, if specied, is reached.
The conversion code convcode indicates how to interpret the input eld. The corresponding
pointer must usually be of a restricted type. You should not specify the pointer parameter for a
suppressed eld.
scanf() processing ends either at the end of the input le, the end of the conversion
specications, or when an input character conicts with the conversion specications. If scanf()
processing ends with an input character conict, the conicting character is not read from the
input stream.
527192-007 Hewlett-Packard Company 611