1SCANF(3)                   Linux Programmer's Manual                  SCANF(3)
2
3
4

NAME

6       scanf,  fscanf, sscanf, vscanf, vsscanf, vfscanf - input format conver‐
7       sion
8

SYNOPSIS

10       #include <stdio.h>
11
12       int scanf(const char *restrict format, ...);
13       int fscanf(FILE *restrict stream,
14                  const char *restrict format, ...);
15       int sscanf(const char *restrict str,
16                  const char *restrict format, ...);
17
18       #include <stdarg.h>
19
20       int vscanf(const char *restrict format, va_list ap);
21       int vfscanf(FILE *restrict stream,
22                  const char *restrict format, va_list ap);
23       int vsscanf(const char *restrict str,
24                  const char *restrict format, va_list ap);
25
26   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
27
28       vscanf(), vsscanf(), vfscanf():
29           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
30

DESCRIPTION

32       The scanf() family of functions scans input according to format as  de‐
33       scribed  below.  This format may contain conversion specifications; the
34       results from such conversions, if any,  are  stored  in  the  locations
35       pointed  to  by the pointer arguments that follow format.  Each pointer
36       argument must be of a type that is appropriate for the  value  returned
37       by the corresponding conversion specification.
38
39       If the number of conversion specifications in format exceeds the number
40       of pointer arguments, the results are  undefined.   If  the  number  of
41       pointer arguments exceeds the number of conversion specifications, then
42       the excess pointer arguments are evaluated, but are otherwise ignored.
43
44       The scanf() function reads input from the standard input stream  stdin,
45       fscanf() reads input from the stream pointer stream, and sscanf() reads
46       its input from the character string pointed to by str.
47
48       The vfscanf() function is analogous to vfprintf(3) and reads input from
49       the  stream  pointer  stream using a variable argument list of pointers
50       (see stdarg(3).  The vscanf() function scans a variable  argument  list
51       from  the  standard  input  and  the vsscanf() function scans it from a
52       string; these are analogous to the vprintf(3) and vsprintf(3) functions
53       respectively.
54
55       The  format  string consists of a sequence of directives which describe
56       how to process the sequence of input characters.  If  processing  of  a
57       directive  fails,  no  further  input  is read, and scanf() returns.  A
58       "failure" can be either of the following: input failure,  meaning  that
59       input  characters  were  unavailable, or matching failure, meaning that
60       the input was inappropriate (see below).
61
62       A directive is one of the following:
63
64       •      A sequence of white-space characters (space, tab, newline, etc.;
65              see  isspace(3)).   This  directive  matches any amount of white
66              space, including none, in the input.
67
68       •      An ordinary character (i.e., one other than white space or '%').
69              This character must exactly match the next character of input.
70
71       •      A conversion specification, which commences with a '%' (percent)