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
◄Summary► ◄Example► ◄Up► ◄Contents► ◄Index► ◄Back►
────────────────────────────────────────────────────────────────────────────
The scanf function reads the standard input stream stdin, uses
the format string to interpret the input as data values, and
assigns those values to the locations specified by the arguments.
The format string can contain format specifications and additional
ordinary characters. Each specification matches an input field in
the input stream and corresponds to an argument.
See: ◄Format Specifiers►
◄Non-Format Characters►
◄Input Fields►
The format string is read from left to right. When a format
specification is encountered, the input field is interpreted
according to that specification, and the resulting value is
assigned to the location specified by the corresponding argument.
If there are more arguments than specifications, the extra
arguments are evaluated but ignored. If there are fewer arguments
than specifications, the results are undefined.
Return Value
The scanf function returns the number of fields converted and
assigned, which may be less than the number of specifications. The
return value does not include fields that were read but not
assigned. The return value is EOF if the end of file or end of
string is encountered in the first attempt to read a character.
-♦-