|
- Parameters:
-
| format | C string that contains a sequence of characters that control how characters extracted from the stream are treated: Whitespace character: the function will read and ignore any whitespace characters encountered before the next non-whitespace character (whitespace characters include spaces, newline and tab characters -- see isspace). A single whitespace in the format string validates any quantity of whitespace characters extracted from the stream (including none). Non-whitespace character, except format specifier (): Any character that is not either a whitespace character (blank, newline or tab) or part of a format specifier (which begin with a character) causes the function to read the next character from the stream, compare it to this non-whitespace character and if it matches, it is discarded and the function continues with the next character of format. If the character does not match, the function fails, returning and leaving subsequent characters of the stream unread. Format specifiers: A sequence formed by an initial percentage sign () indicates a format specifier, which is used to specify the type and format of the data to be retrieved from the stream and stored into the locations pointed by the additional arguments.
A format specifier for scanf follows this prototype: specifier
-s for C string
-d and -u for decimal numbers
-f for floating point single precision -x for hex numbers -c for characters |
| ... | Depending on the format string, the function may expect a sequence of additional arguments, each containing a pointer to allocated storage where the interpretation of the extracted characters is stored with the appropriate type. There should be at least as many of these arguments as the number of values stored by the format specifiers. Additional arguments are ignored by the function. These arguments are expected to be pointers: to store the result of a scanf operation on a regular variable, its name should be preceded by the reference operator (&). |
- Returns:
- On success, the function returns the number of items in the argument list successfully filled.
|