HP C/iX Library Reference Manual (30026-90004)
Chapter 5 179
HP C/iX Library Function Descriptions
fscanf
are called conversion characters. The integer and floating-point conversion characters
may be optionally preceded by a character indicating the size of the receiving variable.
When a conversion specification is encountered in a format, it is matched up with the
corresponding item in the item list. The data formatted by that specification is then stored
in the location pointed to by that item. For example, if there are four conversion
specifications in a format, the first specification is matched up with the first item, the
second specification with the second item, and so on.
The number of conversion specifications in the format is directly related to the number of
items specified in the item list. With one exception, there must be at least as many items
as there are conversion specifications in the format. If there are too few items in the item
list, an error occurs; if there are too many items, the excess items are ignored. The one
exception occurs when the assignment suppression character (*) is used. If an asterisk
occurs immediately after the percent sign (before the
field
width
, if any), the data formatted by that conversion specification is discarded. No
corresponding item is expected in the item list; this is useful for skipping over unwanted
data in the input.
Conversion Characters
There are 14 conversion characters: five format integer data, three format character data,
three format floating-point data, and three special characters.
The integer conversion characters are:
d A decimal integer is expected.
i A signed integer is expected.
o An octal integer is expected.
u An unsigned decimal integer is expected.
x A hexadecimal integer is expected.
The character conversion characters are:
c A single character is expected, normal skip over leading white space is
suppressed.
s A character string is expected.
[ A character string is expected, normal skip over leading white space is
suppressed.
The floating-point conversion characters are:
e, f, g A floating-point number is expected (the capitalized forms of these
characters are also accepted).
The special characters are:
p Matches an implementation-defined set of sequences.
n No input is consumed. The corresponding argument is a pointer to an
integer into which is written the number of characters read from the input
stream so far by this call to fscanf().