xref: /freebsd/lib/libc/stdio/scanf.3 (revision c6ff3a1bf74d96278726113478b2c66884aab584)
158f0484fSRodney W. Grimes.\" Copyright (c) 1990, 1991, 1993
258f0484fSRodney W. Grimes.\"	The Regents of the University of California.  All rights reserved.
358f0484fSRodney W. Grimes.\"
458f0484fSRodney W. Grimes.\" This code is derived from software contributed to Berkeley by
558f0484fSRodney W. Grimes.\" Chris Torek and the American National Standards Committee X3,
658f0484fSRodney W. Grimes.\" on Information Processing Systems.
758f0484fSRodney W. Grimes.\"
858f0484fSRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without
958f0484fSRodney W. Grimes.\" modification, are permitted provided that the following conditions
1058f0484fSRodney W. Grimes.\" are met:
1158f0484fSRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright
1258f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer.
1358f0484fSRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright
1458f0484fSRodney W. Grimes.\"    notice, this list of conditions and the following disclaimer in the
1558f0484fSRodney W. Grimes.\"    documentation and/or other materials provided with the distribution.
1658f0484fSRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software
1758f0484fSRodney W. Grimes.\"    must display the following acknowledgement:
1858f0484fSRodney W. Grimes.\"	This product includes software developed by the University of
1958f0484fSRodney W. Grimes.\"	California, Berkeley and its contributors.
2058f0484fSRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors
2158f0484fSRodney W. Grimes.\"    may be used to endorse or promote products derived from this software
2258f0484fSRodney W. Grimes.\"    without specific prior written permission.
2358f0484fSRodney W. Grimes.\"
2458f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2558f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2658f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2758f0484fSRodney W. Grimes.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2858f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2958f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3058f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3158f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
3258f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3358f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3458f0484fSRodney W. Grimes.\" SUCH DAMAGE.
3558f0484fSRodney W. Grimes.\"
3658f0484fSRodney W. Grimes.\"     @(#)scanf.3	8.2 (Berkeley) 12/11/93
377f3dea24SPeter Wemm.\" $FreeBSD$
3858f0484fSRodney W. Grimes.\"
3958f0484fSRodney W. Grimes.Dd December 11, 1993
4058f0484fSRodney W. Grimes.Dt SCANF 3
4158f0484fSRodney W. Grimes.Os
4258f0484fSRodney W. Grimes.Sh NAME
4358f0484fSRodney W. Grimes.Nm scanf ,
4458f0484fSRodney W. Grimes.Nm fscanf ,
4558f0484fSRodney W. Grimes.Nm sscanf ,
4658f0484fSRodney W. Grimes.Nm vscanf ,
4758f0484fSRodney W. Grimes.Nm vsscanf ,
4858f0484fSRodney W. Grimes.Nm vfscanf
4958f0484fSRodney W. Grimes.Nd input format conversion
5058f0484fSRodney W. Grimes.Sh SYNOPSIS
5158f0484fSRodney W. Grimes.Fd #include <stdio.h>
5258f0484fSRodney W. Grimes.Ft int
5358f0484fSRodney W. Grimes.Fn scanf "const char *format" ...
5458f0484fSRodney W. Grimes.Ft int
5558f0484fSRodney W. Grimes.Fn fscanf "FILE *stream" "const char *format" ...
5658f0484fSRodney W. Grimes.Ft int
5758f0484fSRodney W. Grimes.Fn sscanf "const char *str" "const char *format" ...
5858f0484fSRodney W. Grimes.Fd #include <stdarg.h>
5958f0484fSRodney W. Grimes.Ft int
6058f0484fSRodney W. Grimes.Fn vscanf "const char *format" "va_list ap"
6158f0484fSRodney W. Grimes.Ft int
6258f0484fSRodney W. Grimes.Fn vsscanf "const char *str" "const char *format" "va_list ap"
6358f0484fSRodney W. Grimes.Ft int
6458f0484fSRodney W. Grimes.Fn vfscanf "FILE *stream" "const char *format" "va_list ap"
6558f0484fSRodney W. Grimes.Sh DESCRIPTION
6658f0484fSRodney W. GrimesThe
6758f0484fSRodney W. Grimes.Fn scanf
6858f0484fSRodney W. Grimesfamily of functions scans input according to a
6958f0484fSRodney W. Grimes.Fa format
7058f0484fSRodney W. Grimesas described below.
7158f0484fSRodney W. GrimesThis format may contain
7258f0484fSRodney W. Grimes.Em conversion specifiers ;
7358f0484fSRodney W. Grimesthe results from such conversions, if any,
7458f0484fSRodney W. Grimesare stored through the
7558f0484fSRodney W. Grimes.Em pointer
7658f0484fSRodney W. Grimesarguments.
7758f0484fSRodney W. GrimesThe
7858f0484fSRodney W. Grimes.Fn scanf
7958f0484fSRodney W. Grimesfunction
8058f0484fSRodney W. Grimesreads input from the standard input stream
8158f0484fSRodney W. Grimes.Em stdin ,
8258f0484fSRodney W. Grimes.Fn fscanf
8358f0484fSRodney W. Grimesreads input from the stream pointer
8458f0484fSRodney W. Grimes.Fa stream ,
8558f0484fSRodney W. Grimesand
8658f0484fSRodney W. Grimes.Fn sscanf
8758f0484fSRodney W. Grimesreads its input from the character string pointed to by
8858f0484fSRodney W. Grimes.Fa str .
8958f0484fSRodney W. GrimesThe
9058f0484fSRodney W. Grimes.Fn vfscanf
9158f0484fSRodney W. Grimesfunction
9258f0484fSRodney W. Grimesis analogous to
9358f0484fSRodney W. Grimes.Xr vfprintf 3
9458f0484fSRodney W. Grimesand reads input from the stream pointer
9558f0484fSRodney W. Grimes.Fa stream
9658f0484fSRodney W. Grimesusing a variable argument list of pointers (see
9758f0484fSRodney W. Grimes.Xr stdarg 3 ) .
9858f0484fSRodney W. GrimesThe
9958f0484fSRodney W. Grimes.Fn vscanf
10058f0484fSRodney W. Grimesfunction scans a variable argument list from the standard input and
10158f0484fSRodney W. Grimesthe
10258f0484fSRodney W. Grimes.Fn vsscanf
10358f0484fSRodney W. Grimesfunction scans it from a string;
10458f0484fSRodney W. Grimesthese are analogous to
10558f0484fSRodney W. Grimesthe
10658f0484fSRodney W. Grimes.Fn vprintf
10758f0484fSRodney W. Grimesand
10858f0484fSRodney W. Grimes.Fn vsprintf
10958f0484fSRodney W. Grimesfunctions respectively.
11058f0484fSRodney W. GrimesEach successive
11158f0484fSRodney W. Grimes.Em pointer
11258f0484fSRodney W. Grimesargument must correspond properly with
11358f0484fSRodney W. Grimeseach successive conversion specifier
11458f0484fSRodney W. Grimes(but see `suppression' below).
11558f0484fSRodney W. GrimesAll conversions are introduced by the
11658f0484fSRodney W. Grimes.Cm %
11758f0484fSRodney W. Grimes(percent sign) character.
11858f0484fSRodney W. GrimesThe
11958f0484fSRodney W. Grimes.Fa format
12058f0484fSRodney W. Grimesstring
12158f0484fSRodney W. Grimesmay also contain other characters.
12258f0484fSRodney W. GrimesWhite space (such as blanks, tabs, or newlines) in the
12358f0484fSRodney W. Grimes.Fa format
12458f0484fSRodney W. Grimesstring match any amount of white space, including none, in the input.
12558f0484fSRodney W. GrimesEverything else
12658f0484fSRodney W. Grimesmatches only itself.
12758f0484fSRodney W. GrimesScanning stops
12858f0484fSRodney W. Grimeswhen an input character does not match such a format character.
12958f0484fSRodney W. GrimesScanning also stops
13058f0484fSRodney W. Grimeswhen an input conversion cannot be made (see below).
13158f0484fSRodney W. Grimes.Sh CONVERSIONS
13258f0484fSRodney W. GrimesFollowing the
13358f0484fSRodney W. Grimes.Cm %
13458f0484fSRodney W. Grimescharacter introducing a conversion
13558f0484fSRodney W. Grimesthere may be a number of
13658f0484fSRodney W. Grimes.Em flag
13758f0484fSRodney W. Grimescharacters, as follows:
13858f0484fSRodney W. Grimes.Bl -tag -width indent
13958f0484fSRodney W. Grimes.It Cm *
14058f0484fSRodney W. GrimesSuppresses assignment.
14158f0484fSRodney W. GrimesThe conversion that follows occurs as usual, but no pointer is used;
14258f0484fSRodney W. Grimesthe result of the conversion is simply discarded.
14358f0484fSRodney W. Grimes.It Cm h
14458f0484fSRodney W. GrimesIndicates that the conversion will be one of
14558f0484fSRodney W. Grimes.Cm dioux
14658f0484fSRodney W. Grimesor
14758f0484fSRodney W. Grimes.Cm n
14858f0484fSRodney W. Grimesand the next pointer is a pointer to a
14958f0484fSRodney W. Grimes.Em short  int
15058f0484fSRodney W. Grimes(rather than
15158f0484fSRodney W. Grimes.Em int ) .
15258f0484fSRodney W. Grimes.It Cm l
15358f0484fSRodney W. GrimesIndicates either that the conversion will be one of
15458f0484fSRodney W. Grimes.Cm dioux
15558f0484fSRodney W. Grimesor
15658f0484fSRodney W. Grimes.Cm n
15758f0484fSRodney W. Grimesand the next pointer is a pointer to a
15858f0484fSRodney W. Grimes.Em long  int
15958f0484fSRodney W. Grimes(rather than
16058f0484fSRodney W. Grimes.Em int ) ,
16158f0484fSRodney W. Grimesor that the conversion will be one of
16258f0484fSRodney W. Grimes.Cm efg
16358f0484fSRodney W. Grimesand the next pointer is a pointer to
16458f0484fSRodney W. Grimes.Em double
16558f0484fSRodney W. Grimes(rather than
16658f0484fSRodney W. Grimes.Em float ) .
16758f0484fSRodney W. Grimes.It Cm L
16858f0484fSRodney W. GrimesIndicates that the conversion will be
16958f0484fSRodney W. Grimes.Cm efg
17058f0484fSRodney W. Grimesand the next pointer is a pointer to
17158f0484fSRodney W. Grimes.Em long double .
17258f0484fSRodney W. Grimes(This type is not implemented; the
17358f0484fSRodney W. Grimes.Cm L
17458f0484fSRodney W. Grimesflag is currently ignored.)
1755e17038fSJordan K. Hubbard.It Cm q
1765e17038fSJordan K. HubbardIndicates either that the conversion will be one of
1775e17038fSJordan K. Hubbard.Cm dioux
1785e17038fSJordan K. Hubbardor
1795e17038fSJordan K. Hubbard.Cm n
1805e17038fSJordan K. Hubbardand the next pointer is a pointer to a
1815e17038fSJordan K. Hubbard.Em long long int
1825e17038fSJordan K. Hubbard(rather than
1835e17038fSJordan K. Hubbard.Em int ) ,
18458f0484fSRodney W. Grimes.El
18558f0484fSRodney W. Grimes.Pp
18658f0484fSRodney W. GrimesIn addition to these flags,
18758f0484fSRodney W. Grimesthere may be an optional maximum field width,
18858f0484fSRodney W. Grimesexpressed as a decimal integer,
18958f0484fSRodney W. Grimesbetween the
19058f0484fSRodney W. Grimes.Cm %
19158f0484fSRodney W. Grimesand the conversion.
19258f0484fSRodney W. GrimesIf no width is given,
19358f0484fSRodney W. Grimesa default of `infinity' is used (with one exception, below);
19458f0484fSRodney W. Grimesotherwise at most this many characters are scanned
19558f0484fSRodney W. Grimesin processing the conversion.
19658f0484fSRodney W. GrimesBefore conversion begins,
19758f0484fSRodney W. Grimesmost conversions skip white space;
19858f0484fSRodney W. Grimesthis white space is not counted against the field width.
19958f0484fSRodney W. Grimes.Pp
20058f0484fSRodney W. GrimesThe following conversions are available:
20158f0484fSRodney W. Grimes.Bl -tag -width XXXX
20258f0484fSRodney W. Grimes.It Cm %
20358f0484fSRodney W. GrimesMatches a literal `%'.
20458f0484fSRodney W. GrimesThat is, `%\&%' in the format string
20558f0484fSRodney W. Grimesmatches a single input `%' character.
20658f0484fSRodney W. GrimesNo conversion is done, and assignment does not occur.
20758f0484fSRodney W. Grimes.It Cm d
20858f0484fSRodney W. GrimesMatches an optionally signed decimal integer;
20958f0484fSRodney W. Grimesthe next pointer must be a pointer to
21058f0484fSRodney W. Grimes.Em int .
21158f0484fSRodney W. Grimes.It Cm D
21258f0484fSRodney W. GrimesEquivalent to
213064f0074SMike Pritchard.Cm ld ;
21458f0484fSRodney W. Grimesthis exists only for backwards compatibility.
21558f0484fSRodney W. Grimes.It Cm i
21658f0484fSRodney W. GrimesMatches an optionally signed integer;
21758f0484fSRodney W. Grimesthe next pointer must be a pointer to
21858f0484fSRodney W. Grimes.Em int .
21958f0484fSRodney W. GrimesThe integer is read in base 16 if it begins
22058f0484fSRodney W. Grimeswith
22158f0484fSRodney W. Grimes.Ql 0x
22258f0484fSRodney W. Grimesor
22358f0484fSRodney W. Grimes.Ql 0X ,
22458f0484fSRodney W. Grimesin base 8 if it begins with
22558f0484fSRodney W. Grimes.Ql 0 ,
22658f0484fSRodney W. Grimesand in base 10 otherwise.
22758f0484fSRodney W. GrimesOnly characters that correspond to the base are used.
22858f0484fSRodney W. Grimes.It Cm o
22958f0484fSRodney W. GrimesMatches an octal integer;
23058f0484fSRodney W. Grimesthe next pointer must be a pointer to
23158f0484fSRodney W. Grimes.Em unsigned int .
23258f0484fSRodney W. Grimes.It Cm O
23358f0484fSRodney W. GrimesEquivalent to
234064f0074SMike Pritchard.Cm lo ;
23558f0484fSRodney W. Grimesthis exists for backwards compatibility.
23658f0484fSRodney W. Grimes.It Cm u
23758f0484fSRodney W. GrimesMatches an optionally signed decimal integer;
23858f0484fSRodney W. Grimesthe next pointer must be a pointer to
23958f0484fSRodney W. Grimes.Em unsigned int .
24058f0484fSRodney W. Grimes.It Cm x
24158f0484fSRodney W. GrimesMatches an optionally signed hexadecimal integer;
24258f0484fSRodney W. Grimesthe next pointer must be a pointer to
24358f0484fSRodney W. Grimes.Em unsigned int .
24458f0484fSRodney W. Grimes.It Cm X
24558f0484fSRodney W. GrimesEquivalent to
24658f0484fSRodney W. Grimes.Cm lx ;
24758f0484fSRodney W. Grimesthis violates the
24858f0484fSRodney W. Grimes.St -ansiC ,
24958f0484fSRodney W. Grimesbut is backwards compatible with previous
25058f0484fSRodney W. Grimes.Ux
25158f0484fSRodney W. Grimessystems.
25258f0484fSRodney W. Grimes.It Cm f
25358f0484fSRodney W. GrimesMatches an optionally signed floating-point number;
25458f0484fSRodney W. Grimesthe next pointer must be a pointer to
25558f0484fSRodney W. Grimes.Em float .
25658f0484fSRodney W. Grimes.It Cm e
25758f0484fSRodney W. GrimesEquivalent to
25858f0484fSRodney W. Grimes.Cm f .
25958f0484fSRodney W. Grimes.It Cm g
26058f0484fSRodney W. GrimesEquivalent to
26158f0484fSRodney W. Grimes.Cm f .
26258f0484fSRodney W. Grimes.It Cm E
26358f0484fSRodney W. GrimesEquivalent to
26458f0484fSRodney W. Grimes.Cm lf ;
26558f0484fSRodney W. Grimesthis violates the
26658f0484fSRodney W. Grimes.St -ansiC ,
26758f0484fSRodney W. Grimesbut is backwards compatible with previous
26858f0484fSRodney W. Grimes.Ux
26958f0484fSRodney W. Grimessystems.
27058f0484fSRodney W. Grimes.It Cm F
27158f0484fSRodney W. GrimesEquivalent to
27258f0484fSRodney W. Grimes.Cm lf ;
27358f0484fSRodney W. Grimesthis exists only for backwards compatibility.
27458f0484fSRodney W. Grimes.It Cm s
27558f0484fSRodney W. GrimesMatches a sequence of non-white-space characters;
27658f0484fSRodney W. Grimesthe next pointer must be a pointer to
27758f0484fSRodney W. Grimes.Em char ,
27858f0484fSRodney W. Grimesand the array must be large enough to accept all the sequence and the
27958f0484fSRodney W. Grimesterminating
28058f0484fSRodney W. Grimes.Dv NUL
28158f0484fSRodney W. Grimescharacter.
28258f0484fSRodney W. GrimesThe input string stops at white space
28358f0484fSRodney W. Grimesor at the maximum field width, whichever occurs first.
28458f0484fSRodney W. Grimes.It Cm c
28558f0484fSRodney W. GrimesMatches a sequence of
28658f0484fSRodney W. Grimes.Em width
28758f0484fSRodney W. Grimescount
28858f0484fSRodney W. Grimescharacters (default 1);
28958f0484fSRodney W. Grimesthe next pointer must be a pointer to
29058f0484fSRodney W. Grimes.Em char ,
29158f0484fSRodney W. Grimesand there must be enough room for all the characters
29258f0484fSRodney W. Grimes(no terminating
29358f0484fSRodney W. Grimes.Dv NUL
29458f0484fSRodney W. Grimesis added).
29558f0484fSRodney W. GrimesThe usual skip of leading white space is suppressed.
29658f0484fSRodney W. GrimesTo skip white space first, use an explicit space in the format.
29758f0484fSRodney W. Grimes.It Cm \&[
29858f0484fSRodney W. GrimesMatches a nonempty sequence of characters from the specified set
29958f0484fSRodney W. Grimesof accepted characters;
30058f0484fSRodney W. Grimesthe next pointer must be a pointer to
30158f0484fSRodney W. Grimes.Em char ,
30258f0484fSRodney W. Grimesand there must be enough room for all the characters in the string,
30358f0484fSRodney W. Grimesplus a terminating
30458f0484fSRodney W. Grimes.Dv NUL
30558f0484fSRodney W. Grimescharacter.
30658f0484fSRodney W. GrimesThe usual skip of leading white space is suppressed.
30758f0484fSRodney W. GrimesThe string is to be made up of characters in
30858f0484fSRodney W. Grimes(or not in)
30958f0484fSRodney W. Grimesa particular set;
31058f0484fSRodney W. Grimesthe set is defined by the characters between the open bracket
31158f0484fSRodney W. Grimes.Cm [
31258f0484fSRodney W. Grimescharacter
31358f0484fSRodney W. Grimesand a close bracket
31458f0484fSRodney W. Grimes.Cm ]
31558f0484fSRodney W. Grimescharacter.
31658f0484fSRodney W. GrimesThe set
31758f0484fSRodney W. Grimes.Em excludes
31858f0484fSRodney W. Grimesthose characters
31958f0484fSRodney W. Grimesif the first character after the open bracket is a circumflex
32058f0484fSRodney W. Grimes.Cm ^ .
32158f0484fSRodney W. GrimesTo include a close bracket in the set,
32258f0484fSRodney W. Grimesmake it the first character after the open bracket
32358f0484fSRodney W. Grimesor the circumflex;
32458f0484fSRodney W. Grimesany other position will end the set.
32558f0484fSRodney W. GrimesThe hyphen character
32658f0484fSRodney W. Grimes.Cm -
32758f0484fSRodney W. Grimesis also special;
32858f0484fSRodney W. Grimeswhen placed between two other characters,
32958f0484fSRodney W. Grimesit adds all intervening characters to the set.
33058f0484fSRodney W. GrimesTo include a hyphen,
33158f0484fSRodney W. Grimesmake it the last character before the final close bracket.
33258f0484fSRodney W. GrimesFor instance,
33358f0484fSRodney W. Grimes.Ql [^]0-9-]
33458f0484fSRodney W. Grimesmeans the set `everything except close bracket, zero through nine,
33558f0484fSRodney W. Grimesand hyphen'.
33658f0484fSRodney W. GrimesThe string ends with the appearance of a character not in the
33758f0484fSRodney W. Grimes(or, with a circumflex, in) set
33858f0484fSRodney W. Grimesor when the field width runs out.
33958f0484fSRodney W. Grimes.It Cm p
34058f0484fSRodney W. GrimesMatches a pointer value (as printed by
34158f0484fSRodney W. Grimes.Ql %p
34258f0484fSRodney W. Grimesin
34358f0484fSRodney W. Grimes.Xr printf 3 ) ;
34458f0484fSRodney W. Grimesthe next pointer must be a pointer to
34558f0484fSRodney W. Grimes.Em void .
34658f0484fSRodney W. Grimes.It Cm n
34758f0484fSRodney W. GrimesNothing is expected;
34858f0484fSRodney W. Grimesinstead, the number of characters consumed thus far from the input
34958f0484fSRodney W. Grimesis stored through the next pointer,
35058f0484fSRodney W. Grimeswhich must be a pointer to
35158f0484fSRodney W. Grimes.Em int .
35258f0484fSRodney W. GrimesThis is
35358f0484fSRodney W. Grimes.Em not
35458f0484fSRodney W. Grimesa conversion, although it can be suppressed with the
35558f0484fSRodney W. Grimes.Cm *
35658f0484fSRodney W. Grimesflag.
35758f0484fSRodney W. Grimes.El
35858f0484fSRodney W. Grimes.Pp
35958f0484fSRodney W. GrimesFor backwards compatibility,
36058f0484fSRodney W. Grimesother conversion characters (except
36158f0484fSRodney W. Grimes.Ql \e0 )
36258f0484fSRodney W. Grimesare taken as if they were
36358f0484fSRodney W. Grimes.Ql %d
36458f0484fSRodney W. Grimesor, if uppercase,
36558f0484fSRodney W. Grimes.Ql %ld ,
36658f0484fSRodney W. Grimesand a `conversion' of
36758f0484fSRodney W. Grimes.Ql %\e0
36858f0484fSRodney W. Grimescauses an immediate return of
36958f0484fSRodney W. Grimes.Dv EOF .
37058f0484fSRodney W. GrimesThe
37158f0484fSRodney W. Grimes.Cm F
37258f0484fSRodney W. Grimesand
37358f0484fSRodney W. Grimes.Cm X
37458f0484fSRodney W. Grimesconversions will be changed in the future
37558f0484fSRodney W. Grimesto conform to the
37658f0484fSRodney W. Grimes.Tn ANSI
37758f0484fSRodney W. GrimesC standard,
37858f0484fSRodney W. Grimesafter which they will act like
37958f0484fSRodney W. Grimes.Cm f
38058f0484fSRodney W. Grimesand
38158f0484fSRodney W. Grimes.Cm x
38258f0484fSRodney W. Grimesrespectively.
38358f0484fSRodney W. Grimes.Pp
38458f0484fSRodney W. Grimes.Sh RETURN VALUES
38558f0484fSRodney W. GrimesThese
38658f0484fSRodney W. Grimesfunctions
38758f0484fSRodney W. Grimesreturn
38858f0484fSRodney W. Grimesthe number of input items assigned, which can be fewer than provided
38958f0484fSRodney W. Grimesfor, or even zero, in the event of a matching failure.
39058f0484fSRodney W. GrimesZero
39158f0484fSRodney W. Grimesindicates that, while there was input available,
39258f0484fSRodney W. Grimesno conversions were assigned;
39358f0484fSRodney W. Grimestypically this is due to an invalid input character,
39458f0484fSRodney W. Grimessuch as an alphabetic character for a
39558f0484fSRodney W. Grimes.Ql %d
39658f0484fSRodney W. Grimesconversion.
39758f0484fSRodney W. GrimesThe value
39858f0484fSRodney W. Grimes.Dv EOF
39958f0484fSRodney W. Grimesis returned if an input failure occurs before any conversion such as an
400c6ff3a1bSSheldon Hearnend-of-file occurs.
401c6ff3a1bSSheldon HearnIf an error or end-of-file occurs after conversion
40258f0484fSRodney W. Grimeshas begun,
40358f0484fSRodney W. Grimesthe number of conversions which were successfully completed is returned.
40458f0484fSRodney W. Grimes.Sh SEE ALSO
40558f0484fSRodney W. Grimes.Xr getc 3 ,
40675141cc9SWolfram Schneider.Xr printf 3 ,
40775141cc9SWolfram Schneider.Xr strtod 3 ,
40875141cc9SWolfram Schneider.Xr strtol 3 ,
40975141cc9SWolfram Schneider.Xr strtoul 3
41058f0484fSRodney W. Grimes.Sh STANDARDS
41158f0484fSRodney W. GrimesThe functions
41258f0484fSRodney W. Grimes.Fn fscanf ,
41358f0484fSRodney W. Grimes.Fn scanf ,
41458f0484fSRodney W. Grimesand
41558f0484fSRodney W. Grimes.Fn sscanf
41658f0484fSRodney W. Grimesconform to
41758f0484fSRodney W. Grimes.St -ansiC .
41858f0484fSRodney W. Grimes.Sh HISTORY
41958f0484fSRodney W. GrimesThe functions
42058f0484fSRodney W. Grimes.Fn vscanf ,
42158f0484fSRodney W. Grimes.Fn vsscanf
42258f0484fSRodney W. Grimesand
42358f0484fSRodney W. Grimes.Fn vfscanf
42458f0484fSRodney W. Grimesare new to this release.
42558f0484fSRodney W. Grimes.Sh BUGS
42658f0484fSRodney W. GrimesThe current situation with
42758f0484fSRodney W. Grimes.Cm %F
42858f0484fSRodney W. Grimesand
42958f0484fSRodney W. Grimes.Cm %X
43058f0484fSRodney W. Grimesconversions is unfortunate.
43158f0484fSRodney W. Grimes.Pp
43258f0484fSRodney W. GrimesAll of the backwards compatibility formats will be removed in the future.
43358f0484fSRodney W. Grimes.Pp
43458f0484fSRodney W. GrimesNumerical strings are truncated to 512 characters; for example,
43558f0484fSRodney W. Grimes.Cm %f
43658f0484fSRodney W. Grimesand
43758f0484fSRodney W. Grimes.Cm %d
43858f0484fSRodney W. Grimesare implicitly
43958f0484fSRodney W. Grimes.Cm %512f
44058f0484fSRodney W. Grimesand
44158f0484fSRodney W. Grimes.Cm %512d .
442