Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
scanf Format Specifiers
◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
Format specifications are introduced by the percent sign (%) and
have the following form:
% [*] [width] [ { F | N } ] [ { h | l } ] type
Each field of the format specification is a single character or a
number signifying a particular format option. The type character,
which appears after the last optional format field, determines
whether the input field is interpreted as a character, a string,
or a number. The simplest format specification contains only the
percent sign and a type character (for example, %s).
See: ◄Prefixes► ◄Type►
If a percent sign (%) is followed by a character that has no
meaning as a format-control character, that character is treated
as ordinary. For example, to specify that a percent-sign character
is to be input, use %%.
An asterisk (*) following the percent sign suppresses assignment
of the next input field, which is interpreted as a field of the
specified type. The field is scanned but not stored.
The width is a positive decimal integer controlling the maximum
number of characters to be read from stdin. No more than <width>
characters are converted and stored at the corresponding argument.
Fewer than <width> characters may be read if a white-space
character (space, tab, or newline) or a character that cannot
be converted according to the given format occurs before <width>
is reached.
-♦-