HP C/iX Library Reference Manual (30026-90004)

302 Chapter5
HP C/iX Library Function Descriptions
scanf
character, in the array arr4.
Note that there are some characters left in stdin that were not read. Any characters left
unread in the input remain there, which might cause unexpected errors.
Suppose that, later in the above program fragment, you want to read a string from stdin
using %s. No matter what string you type in as input, it will never be read, because the %s
conversion specification is satisfied by reading "mnop" (the characters left over from the
previous read operation). To solve this, be sure you have read the entire current line of
input before attempting to read the next. To fix this in the previous scanf() example, add
a %*s%*c conversion specification at the end of the format (%*s reads characters up to the
next newline character, and %*c reads the newline). This reads and discards the excess
characters.
You can use a minus character (-) between characters in the match list inside a [
conversion specifier to indicate a range of characters. For example, the conversion specifier
[A-Z] matches all the characters from A through Z
See Also
fscanf(), sscanf(), getc(), setlocale(), printf(), strtod(), strtol(), ANSI C
4.9.6.4, POSIX.1 8.1