xref: /minix3/lib/libc/stdio/scanf.3 (revision 2fe8fb192fe7e8720e3e7a77f928da545e872a6a)
1*2fe8fb19SBen Gras.\"	$NetBSD: scanf.3,v 1.27 2010/05/14 03:04:32 joerg Exp $
2*2fe8fb19SBen Gras.\"
3*2fe8fb19SBen Gras.\" Copyright (c) 1990, 1991, 1993
4*2fe8fb19SBen Gras.\"	The Regents of the University of California.  All rights reserved.
5*2fe8fb19SBen Gras.\"
6*2fe8fb19SBen Gras.\" This code is derived from software contributed to Berkeley by
7*2fe8fb19SBen Gras.\" Chris Torek and the American National Standards Committee X3,
8*2fe8fb19SBen Gras.\" on Information Processing Systems.
9*2fe8fb19SBen Gras.\"
10*2fe8fb19SBen Gras.\" Redistribution and use in source and binary forms, with or without
11*2fe8fb19SBen Gras.\" modification, are permitted provided that the following conditions
12*2fe8fb19SBen Gras.\" are met:
13*2fe8fb19SBen Gras.\" 1. Redistributions of source code must retain the above copyright
14*2fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer.
15*2fe8fb19SBen Gras.\" 2. Redistributions in binary form must reproduce the above copyright
16*2fe8fb19SBen Gras.\"    notice, this list of conditions and the following disclaimer in the
17*2fe8fb19SBen Gras.\"    documentation and/or other materials provided with the distribution.
18*2fe8fb19SBen Gras.\" 3. Neither the name of the University nor the names of its contributors
19*2fe8fb19SBen Gras.\"    may be used to endorse or promote products derived from this software
20*2fe8fb19SBen Gras.\"    without specific prior written permission.
21*2fe8fb19SBen Gras.\"
22*2fe8fb19SBen Gras.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23*2fe8fb19SBen Gras.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24*2fe8fb19SBen Gras.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25*2fe8fb19SBen Gras.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26*2fe8fb19SBen Gras.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27*2fe8fb19SBen Gras.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28*2fe8fb19SBen Gras.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29*2fe8fb19SBen Gras.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30*2fe8fb19SBen Gras.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31*2fe8fb19SBen Gras.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32*2fe8fb19SBen Gras.\" SUCH DAMAGE.
33*2fe8fb19SBen Gras.\"
34*2fe8fb19SBen Gras.\"     @(#)scanf.3	8.2 (Berkeley) 12/11/93
35*2fe8fb19SBen Gras.\"
36*2fe8fb19SBen Gras.Dd March 21, 2010
37*2fe8fb19SBen Gras.Dt SCANF 3
38*2fe8fb19SBen Gras.Os
39*2fe8fb19SBen Gras.Sh NAME
40*2fe8fb19SBen Gras.Nm scanf ,
41*2fe8fb19SBen Gras.Nm fscanf ,
42*2fe8fb19SBen Gras.Nm sscanf ,
43*2fe8fb19SBen Gras.Nm vscanf ,
44*2fe8fb19SBen Gras.Nm vsscanf ,
45*2fe8fb19SBen Gras.Nm vfscanf
46*2fe8fb19SBen Gras.Nd input format conversion
47*2fe8fb19SBen Gras.Sh LIBRARY
48*2fe8fb19SBen Gras.Lb libc
49*2fe8fb19SBen Gras.Sh SYNOPSIS
50*2fe8fb19SBen Gras.In stdio.h
51*2fe8fb19SBen Gras.Ft int
52*2fe8fb19SBen Gras.Fn scanf "const char * restrict format" ...
53*2fe8fb19SBen Gras.Ft int
54*2fe8fb19SBen Gras.Fn fscanf "FILE * restrict stream" "const char * restrict format" ...
55*2fe8fb19SBen Gras.Ft int
56*2fe8fb19SBen Gras.Fn sscanf "const char * restrict str" "const char * restrict format" ...
57*2fe8fb19SBen Gras.In stdarg.h
58*2fe8fb19SBen Gras.Ft int
59*2fe8fb19SBen Gras.Fn vscanf "const char * restrict format" "va_list ap"
60*2fe8fb19SBen Gras.Ft int
61*2fe8fb19SBen Gras.Fn vsscanf "const char * restrict str" "const char * restrict format" "va_list ap"
62*2fe8fb19SBen Gras.Ft int
63*2fe8fb19SBen Gras.Fn vfscanf "FILE * restrict stream" "const char * restrict format" "va_list ap"
64*2fe8fb19SBen Gras.Sh DESCRIPTION
65*2fe8fb19SBen GrasThe
66*2fe8fb19SBen Gras.Fn scanf
67*2fe8fb19SBen Grasfamily of functions scans input according to a
68*2fe8fb19SBen Gras.Fa format
69*2fe8fb19SBen Grasas described below.
70*2fe8fb19SBen GrasThis format may contain
71*2fe8fb19SBen Gras.Em conversion specifiers ;
72*2fe8fb19SBen Grasthe results from such conversions, if any,
73*2fe8fb19SBen Grasare stored through the
74*2fe8fb19SBen Gras.Em pointer
75*2fe8fb19SBen Grasarguments.
76*2fe8fb19SBen Gras.Pp
77*2fe8fb19SBen GrasThe
78*2fe8fb19SBen Gras.Fn scanf
79*2fe8fb19SBen Grasfunction
80*2fe8fb19SBen Grasreads input from the standard input stream
81*2fe8fb19SBen Gras.Em stdin ,
82*2fe8fb19SBen Gras.Fn fscanf
83*2fe8fb19SBen Grasreads input from the stream pointer
84*2fe8fb19SBen Gras.Fa stream ,
85*2fe8fb19SBen Grasand
86*2fe8fb19SBen Gras.Fn sscanf
87*2fe8fb19SBen Grasreads its input from the character string pointed to by
88*2fe8fb19SBen Gras.Fa str .
89*2fe8fb19SBen GrasThe
90*2fe8fb19SBen Gras.Fn vfscanf
91*2fe8fb19SBen Grasfunction
92*2fe8fb19SBen Grasis analogous to
93*2fe8fb19SBen Gras.Xr vfprintf 3
94*2fe8fb19SBen Grasand reads input from the stream pointer
95*2fe8fb19SBen Gras.Fa stream
96*2fe8fb19SBen Grasusing a variable argument list of pointers (see
97*2fe8fb19SBen Gras.Xr stdarg 3 ) .
98*2fe8fb19SBen GrasThe
99*2fe8fb19SBen Gras.Fn vscanf
100*2fe8fb19SBen Grasfunction scans a variable argument list from the standard input and
101*2fe8fb19SBen Grasthe
102*2fe8fb19SBen Gras.Fn vsscanf
103*2fe8fb19SBen Grasfunction scans it from a string;
104*2fe8fb19SBen Grasthese are analogous to
105*2fe8fb19SBen Grasthe
106*2fe8fb19SBen Gras.Fn vprintf
107*2fe8fb19SBen Grasand
108*2fe8fb19SBen Gras.Fn vsprintf
109*2fe8fb19SBen Grasfunctions respectively.
110*2fe8fb19SBen Gras.Pp
111*2fe8fb19SBen GrasEach successive
112*2fe8fb19SBen Gras.Em pointer
113*2fe8fb19SBen Grasargument must correspond properly with
114*2fe8fb19SBen Graseach successive conversion specifier
115*2fe8fb19SBen Gras(but see `suppression' below).
116*2fe8fb19SBen GrasAll conversions are introduced by the
117*2fe8fb19SBen Gras.Cm %
118*2fe8fb19SBen Gras(percent sign) character.
119*2fe8fb19SBen GrasThe
120*2fe8fb19SBen Gras.Fa format
121*2fe8fb19SBen Grasstring
122*2fe8fb19SBen Grasmay also contain other characters.
123*2fe8fb19SBen GrasWhite space (such as blanks, tabs, or newlines) in the
124*2fe8fb19SBen Gras.Fa format
125*2fe8fb19SBen Grasstring match any amount of white space, including none, in the input.
126*2fe8fb19SBen GrasEverything else
127*2fe8fb19SBen Grasmatches only itself.
128*2fe8fb19SBen GrasScanning stops
129*2fe8fb19SBen Graswhen an input character does not match such a format character.
130*2fe8fb19SBen GrasScanning also stops
131*2fe8fb19SBen Graswhen an input conversion cannot be made (see below).
132*2fe8fb19SBen Gras.Sh CONVERSIONS
133*2fe8fb19SBen GrasFollowing the
134*2fe8fb19SBen Gras.Cm %
135*2fe8fb19SBen Grascharacter introducing a conversion
136*2fe8fb19SBen Grasthere may be a number of
137*2fe8fb19SBen Gras.Em flag
138*2fe8fb19SBen Grascharacters, as follows:
139*2fe8fb19SBen Gras.Bl -tag -width indent
140*2fe8fb19SBen Gras.It Cm *
141*2fe8fb19SBen GrasSuppresses assignment.
142*2fe8fb19SBen GrasThe conversion that follows occurs as usual, but no pointer is used;
143*2fe8fb19SBen Grasthe result of the conversion is simply discarded.
144*2fe8fb19SBen Gras.It Cm h
145*2fe8fb19SBen GrasIndicates that the conversion will be one of
146*2fe8fb19SBen Gras.Cm dioux
147*2fe8fb19SBen Grasor
148*2fe8fb19SBen Gras.Cm n
149*2fe8fb19SBen Grasand the next pointer is a pointer to a
150*2fe8fb19SBen Gras.Em short int
151*2fe8fb19SBen Gras(rather than
152*2fe8fb19SBen Gras.Em int ) .
153*2fe8fb19SBen Gras.It Cm hh
154*2fe8fb19SBen GrasIndicates that the conversion will be one of
155*2fe8fb19SBen Gras.Cm dioux
156*2fe8fb19SBen Grasor
157*2fe8fb19SBen Gras.Cm n
158*2fe8fb19SBen Grasand the next pointer is a pointer to a
159*2fe8fb19SBen Gras.Em char
160*2fe8fb19SBen Gras(rather than
161*2fe8fb19SBen Gras.Em int ) .
162*2fe8fb19SBen Gras.It Cm j
163*2fe8fb19SBen GrasIndicates that the conversion will be one of
164*2fe8fb19SBen Gras.Cm dioux
165*2fe8fb19SBen Grasor
166*2fe8fb19SBen Gras.Cm n
167*2fe8fb19SBen Grasand the next pointer is a pointer to an
168*2fe8fb19SBen Gras.Em intmax_t
169*2fe8fb19SBen Gras(rather than
170*2fe8fb19SBen Gras.Em int ) .
171*2fe8fb19SBen Gras.It Cm l
172*2fe8fb19SBen GrasIndicates either that the conversion will be one of
173*2fe8fb19SBen Gras.Cm dioux
174*2fe8fb19SBen Grasor
175*2fe8fb19SBen Gras.Cm n
176*2fe8fb19SBen Grasand the next pointer is a pointer to a
177*2fe8fb19SBen Gras.Em long int
178*2fe8fb19SBen Gras(rather than
179*2fe8fb19SBen Gras.Em int ) ,
180*2fe8fb19SBen Grasor that the conversion will be one of
181*2fe8fb19SBen Gras.Cm efg
182*2fe8fb19SBen Grasand the next pointer is a pointer to
183*2fe8fb19SBen Gras.Em double
184*2fe8fb19SBen Gras(rather than
185*2fe8fb19SBen Gras.Em float ) .
186*2fe8fb19SBen Gras.It Cm ll
187*2fe8fb19SBen GrasIndicates that the conversion will be one of
188*2fe8fb19SBen Gras.Cm dioux
189*2fe8fb19SBen Grasor
190*2fe8fb19SBen Gras.Cm n
191*2fe8fb19SBen Grasand the next pointer is a pointer to a
192*2fe8fb19SBen Gras.Em long long int
193*2fe8fb19SBen Gras(rather than
194*2fe8fb19SBen Gras.Em int ) .
195*2fe8fb19SBen Gras.It Cm q
196*2fe8fb19SBen GrasIndicates that the conversion will be one of
197*2fe8fb19SBen Gras.Cm dioux
198*2fe8fb19SBen Grasor
199*2fe8fb19SBen Gras.Cm n
200*2fe8fb19SBen Grasand the next pointer is a pointer to a
201*2fe8fb19SBen Gras.Em quad_t
202*2fe8fb19SBen Gras(rather than
203*2fe8fb19SBen Gras.Em int ) .
204*2fe8fb19SBen Gras.It Cm t
205*2fe8fb19SBen GrasIndicates that the conversion will be one of
206*2fe8fb19SBen Gras.Cm dioux
207*2fe8fb19SBen Grasor
208*2fe8fb19SBen Gras.Cm n
209*2fe8fb19SBen Grasand the next pointer is a pointer to a
210*2fe8fb19SBen Gras.Em ptrdiff_t
211*2fe8fb19SBen Gras(rather than
212*2fe8fb19SBen Gras.Em int ) .
213*2fe8fb19SBen Gras.It Cm z
214*2fe8fb19SBen GrasIndicates that the conversion will be one of
215*2fe8fb19SBen Gras.Cm dioux
216*2fe8fb19SBen Grasor
217*2fe8fb19SBen Gras.Cm n
218*2fe8fb19SBen Grasand the next pointer is a pointer to a
219*2fe8fb19SBen Gras.Em size_t
220*2fe8fb19SBen Gras(rather than
221*2fe8fb19SBen Gras.Em int ) .
222*2fe8fb19SBen Gras.It Cm L
223*2fe8fb19SBen GrasIndicates that the conversion will be
224*2fe8fb19SBen Gras.Cm efg
225*2fe8fb19SBen Grasand the next pointer is a pointer to
226*2fe8fb19SBen Gras.Em long double .
227*2fe8fb19SBen Gras.El
228*2fe8fb19SBen Gras.Pp
229*2fe8fb19SBen GrasIn addition to these flags,
230*2fe8fb19SBen Grasthere may be an optional maximum field width,
231*2fe8fb19SBen Grasexpressed as a decimal integer,
232*2fe8fb19SBen Grasbetween the
233*2fe8fb19SBen Gras.Cm %
234*2fe8fb19SBen Grasand the conversion.
235*2fe8fb19SBen GrasIf no width is given,
236*2fe8fb19SBen Grasa default of `infinity' is used (with one exception, below);
237*2fe8fb19SBen Grasotherwise at most this many characters are scanned
238*2fe8fb19SBen Grasin processing the conversion.
239*2fe8fb19SBen GrasBefore conversion begins,
240*2fe8fb19SBen Grasmost conversions skip white space;
241*2fe8fb19SBen Grasthis white space is not counted against the field width.
242*2fe8fb19SBen Gras.Pp
243*2fe8fb19SBen GrasThe following conversions are available:
244*2fe8fb19SBen Gras.Bl -tag -width XXXX
245*2fe8fb19SBen Gras.It Cm %
246*2fe8fb19SBen GrasMatches a literal `%'.
247*2fe8fb19SBen GrasThat is, `%\&%' in the format string
248*2fe8fb19SBen Grasmatches a single input `%' character.
249*2fe8fb19SBen GrasNo conversion is done, and assignment does not occur.
250*2fe8fb19SBen Gras.It Cm d
251*2fe8fb19SBen GrasMatches an optionally signed decimal integer;
252*2fe8fb19SBen Grasthe next pointer must be a pointer to
253*2fe8fb19SBen Gras.Em int .
254*2fe8fb19SBen Gras.It Cm D
255*2fe8fb19SBen GrasEquivalent to
256*2fe8fb19SBen Gras.Cm ld ;
257*2fe8fb19SBen Grasthis exists only for backwards compatibility.
258*2fe8fb19SBen Gras.It Cm i
259*2fe8fb19SBen GrasMatches an optionally signed integer;
260*2fe8fb19SBen Grasthe next pointer must be a pointer to
261*2fe8fb19SBen Gras.Em int .
262*2fe8fb19SBen GrasThe integer is read in base 16 if it begins
263*2fe8fb19SBen Graswith
264*2fe8fb19SBen Gras.Ql 0x
265*2fe8fb19SBen Grasor
266*2fe8fb19SBen Gras.Ql 0X ,
267*2fe8fb19SBen Grasin base 8 if it begins with
268*2fe8fb19SBen Gras.Ql 0 ,
269*2fe8fb19SBen Grasand in base 10 otherwise.
270*2fe8fb19SBen GrasOnly characters that correspond to the base are used.
271*2fe8fb19SBen Gras.It Cm o
272*2fe8fb19SBen GrasMatches an octal integer;
273*2fe8fb19SBen Grasthe next pointer must be a pointer to
274*2fe8fb19SBen Gras.Em unsigned int .
275*2fe8fb19SBen Gras.It Cm O
276*2fe8fb19SBen GrasEquivalent to
277*2fe8fb19SBen Gras.Cm lo ;
278*2fe8fb19SBen Grasthis exists for backwards compatibility.
279*2fe8fb19SBen Gras.It Cm u
280*2fe8fb19SBen GrasMatches an optionally signed decimal integer;
281*2fe8fb19SBen Grasthe next pointer must be a pointer to
282*2fe8fb19SBen Gras.Em unsigned int .
283*2fe8fb19SBen Gras.It Cm x
284*2fe8fb19SBen GrasMatches an optionally signed hexadecimal integer;
285*2fe8fb19SBen Grasthe next pointer must be a pointer to
286*2fe8fb19SBen Gras.Em unsigned int .
287*2fe8fb19SBen Gras.It Cm X
288*2fe8fb19SBen GrasEquivalent to
289*2fe8fb19SBen Gras.Cm x .
290*2fe8fb19SBen Gras.It Cm f
291*2fe8fb19SBen GrasMatches an optionally signed floating-point number;
292*2fe8fb19SBen Grasthe next pointer must be a pointer to
293*2fe8fb19SBen Gras.Em float .
294*2fe8fb19SBen Gras.It Cm e
295*2fe8fb19SBen GrasEquivalent to
296*2fe8fb19SBen Gras.Cm f .
297*2fe8fb19SBen Gras.It Cm g
298*2fe8fb19SBen GrasEquivalent to
299*2fe8fb19SBen Gras.Cm f .
300*2fe8fb19SBen Gras.It Cm E
301*2fe8fb19SBen GrasEquivalent to
302*2fe8fb19SBen Gras.Cm f .
303*2fe8fb19SBen Gras.It Cm G
304*2fe8fb19SBen GrasEquivalent to
305*2fe8fb19SBen Gras.Cm f .
306*2fe8fb19SBen Gras.It Cm s
307*2fe8fb19SBen GrasMatches a sequence of non-white-space characters;
308*2fe8fb19SBen Grasthe next pointer must be a pointer to
309*2fe8fb19SBen Gras.Em char ,
310*2fe8fb19SBen Grasand the array must be large enough to accept all the sequence and the
311*2fe8fb19SBen Grasterminating
312*2fe8fb19SBen Gras.Dv NUL
313*2fe8fb19SBen Grascharacter.
314*2fe8fb19SBen GrasThe input string stops at white space
315*2fe8fb19SBen Grasor at the maximum field width, whichever occurs first.
316*2fe8fb19SBen Gras.It Cm c
317*2fe8fb19SBen GrasMatches a sequence of
318*2fe8fb19SBen Gras.Em width
319*2fe8fb19SBen Grascount
320*2fe8fb19SBen Grascharacters (default 1);
321*2fe8fb19SBen Grasthe next pointer must be a pointer to
322*2fe8fb19SBen Gras.Em char ,
323*2fe8fb19SBen Grasand there must be enough room for all the characters
324*2fe8fb19SBen Gras(no terminating
325*2fe8fb19SBen Gras.Dv NUL
326*2fe8fb19SBen Grasis added).
327*2fe8fb19SBen GrasThe usual skip of leading white space is suppressed.
328*2fe8fb19SBen GrasTo skip white space first, use an explicit space in the format.
329*2fe8fb19SBen Gras.It Cm \&[
330*2fe8fb19SBen GrasMatches a nonempty sequence of characters from the specified set
331*2fe8fb19SBen Grasof accepted characters;
332*2fe8fb19SBen Grasthe next pointer must be a pointer to
333*2fe8fb19SBen Gras.Em char ,
334*2fe8fb19SBen Grasand there must be enough room for all the characters in the string,
335*2fe8fb19SBen Grasplus a terminating
336*2fe8fb19SBen Gras.Dv NUL
337*2fe8fb19SBen Grascharacter.
338*2fe8fb19SBen GrasThe usual skip of leading white space is suppressed.
339*2fe8fb19SBen GrasThe string is to be made up of characters in
340*2fe8fb19SBen Gras(or not in)
341*2fe8fb19SBen Grasa particular set;
342*2fe8fb19SBen Grasthe set is defined by the characters between the open bracket
343*2fe8fb19SBen Gras.Cm \&[
344*2fe8fb19SBen Grascharacter
345*2fe8fb19SBen Grasand a close bracket
346*2fe8fb19SBen Gras.Cm \&]
347*2fe8fb19SBen Grascharacter.
348*2fe8fb19SBen GrasThe set
349*2fe8fb19SBen Gras.Em excludes
350*2fe8fb19SBen Grasthose characters
351*2fe8fb19SBen Grasif the first character after the open bracket is a circumflex
352*2fe8fb19SBen Gras.Cm ^ .
353*2fe8fb19SBen GrasTo include a close bracket in the set,
354*2fe8fb19SBen Grasmake it the first character after the open bracket
355*2fe8fb19SBen Grasor the circumflex;
356*2fe8fb19SBen Grasany other position will end the set.
357*2fe8fb19SBen GrasThe hyphen character
358*2fe8fb19SBen Gras.Cm -
359*2fe8fb19SBen Grasis also special;
360*2fe8fb19SBen Graswhen placed between two other characters,
361*2fe8fb19SBen Grasit adds all intervening characters to the set.
362*2fe8fb19SBen GrasTo include a hyphen,
363*2fe8fb19SBen Grasmake it the last character before the final close bracket.
364*2fe8fb19SBen GrasFor instance,
365*2fe8fb19SBen Gras.Ql [^]0-9-]
366*2fe8fb19SBen Grasmeans the set `everything except close bracket, zero through nine,
367*2fe8fb19SBen Grasand hyphen'.
368*2fe8fb19SBen GrasThe string ends with the appearance of a character not in the
369*2fe8fb19SBen Gras(or, with a circumflex, in) set
370*2fe8fb19SBen Grasor when the field width runs out.
371*2fe8fb19SBen Gras.It Cm p
372*2fe8fb19SBen GrasMatches a pointer value (as printed by
373*2fe8fb19SBen Gras.Ql %p
374*2fe8fb19SBen Grasin
375*2fe8fb19SBen Gras.Xr printf 3 ) ;
376*2fe8fb19SBen Grasthe next pointer must be a pointer to
377*2fe8fb19SBen Gras.Em void .
378*2fe8fb19SBen Gras.It Cm n
379*2fe8fb19SBen GrasNothing is expected;
380*2fe8fb19SBen Grasinstead, the number of characters consumed thus far from the input
381*2fe8fb19SBen Grasis stored through the next pointer,
382*2fe8fb19SBen Graswhich must be a pointer to
383*2fe8fb19SBen Gras.Em int .
384*2fe8fb19SBen GrasThis is
385*2fe8fb19SBen Gras.Em not
386*2fe8fb19SBen Grasa conversion, although it can be suppressed with the
387*2fe8fb19SBen Gras.Cm *
388*2fe8fb19SBen Grasflag.
389*2fe8fb19SBen Gras.El
390*2fe8fb19SBen Gras.Pp
391*2fe8fb19SBen GrasFor backwards compatibility,
392*2fe8fb19SBen Grasother conversion characters (except
393*2fe8fb19SBen Gras.Ql \e0 )
394*2fe8fb19SBen Grasare taken as if they were
395*2fe8fb19SBen Gras.Ql %d
396*2fe8fb19SBen Grasor, if uppercase,
397*2fe8fb19SBen Gras.Ql %ld ,
398*2fe8fb19SBen Grasand a `conversion' of
399*2fe8fb19SBen Gras.Ql %\e0
400*2fe8fb19SBen Grascauses an immediate return of
401*2fe8fb19SBen Gras.Dv EOF .
402*2fe8fb19SBen Gras.Pp
403*2fe8fb19SBen GrasThe format string specifier macros described in
404*2fe8fb19SBen Gras.Xr inttypes 3
405*2fe8fb19SBen Grasshould be used for the standard
406*2fe8fb19SBen Gras.Dq C99
407*2fe8fb19SBen Grasfixed-size integers documented in
408*2fe8fb19SBen Gras.Xr stdint 3 .
409*2fe8fb19SBen Gras.Sh RETURN VALUES
410*2fe8fb19SBen GrasThese
411*2fe8fb19SBen Grasfunctions
412*2fe8fb19SBen Grasreturn
413*2fe8fb19SBen Grasthe number of input items assigned, which can be fewer than provided
414*2fe8fb19SBen Grasfor, or even zero, in the event of a matching failure.
415*2fe8fb19SBen GrasZero
416*2fe8fb19SBen Grasindicates that, while there was input available,
417*2fe8fb19SBen Grasno conversions were assigned;
418*2fe8fb19SBen Grastypically this is due to an invalid input character,
419*2fe8fb19SBen Grassuch as an alphabetic character for a
420*2fe8fb19SBen Gras.Ql %d
421*2fe8fb19SBen Grasconversion.
422*2fe8fb19SBen GrasThe value
423*2fe8fb19SBen Gras.Dv EOF
424*2fe8fb19SBen Grasis returned if an input failure occurs before any conversion such as an
425*2fe8fb19SBen Grasend-of-file occurs.
426*2fe8fb19SBen GrasIf an error or end-of-file occurs after conversion has begun,
427*2fe8fb19SBen Grasthe number of conversions which were successfully completed is returned.
428*2fe8fb19SBen Gras.Sh SEE ALSO
429*2fe8fb19SBen Gras.Xr getc 3 ,
430*2fe8fb19SBen Gras.Xr inttypes 3 ,
431*2fe8fb19SBen Gras.Xr printf 3 ,
432*2fe8fb19SBen Gras.Xr strtod 3 ,
433*2fe8fb19SBen Gras.Xr strtol 3 ,
434*2fe8fb19SBen Gras.Xr strtoul 3
435*2fe8fb19SBen Gras.Sh STANDARDS
436*2fe8fb19SBen GrasThe functions
437*2fe8fb19SBen Gras.Fn fscanf ,
438*2fe8fb19SBen Gras.Fn scanf ,
439*2fe8fb19SBen Grasand
440*2fe8fb19SBen Gras.Fn sscanf
441*2fe8fb19SBen Grasconform to
442*2fe8fb19SBen Gras.St -isoC-90 .
443*2fe8fb19SBen GrasThe
444*2fe8fb19SBen Gras.Cm %j ,
445*2fe8fb19SBen Gras.Cm %t
446*2fe8fb19SBen Grasand
447*2fe8fb19SBen Gras.Cm %z
448*2fe8fb19SBen Grasconversion format modifiers
449*2fe8fb19SBen Grasconform to
450*2fe8fb19SBen Gras.St -isoC-99 .
451*2fe8fb19SBen GrasThe
452*2fe8fb19SBen Gras.Fn vfscanf ,
453*2fe8fb19SBen Gras.Fn vscanf
454*2fe8fb19SBen Grasand
455*2fe8fb19SBen Gras.Fn vsscanf
456*2fe8fb19SBen Grasfunctions conform to
457*2fe8fb19SBen Gras.St -isoC-99 .
458*2fe8fb19SBen Gras.Sh HISTORY
459*2fe8fb19SBen GrasThe functions
460*2fe8fb19SBen Gras.Fn vscanf ,
461*2fe8fb19SBen Gras.Fn vsscanf
462*2fe8fb19SBen Grasand
463*2fe8fb19SBen Gras.Fn vfscanf
464*2fe8fb19SBen Grasappeared in
465*2fe8fb19SBen Gras.Bx 4.4
466*2fe8fb19SBen Grasor even
467*2fe8fb19SBen Gras.Bx 4.3 .
468*2fe8fb19SBen Gras.Sh NOTES
469*2fe8fb19SBen GrasAll of the backwards compatibility formats will be removed in the future.
470*2fe8fb19SBen Gras.Sh BUGS
471*2fe8fb19SBen GrasNumerical strings are truncated to 512 characters; for example,
472*2fe8fb19SBen Gras.Cm %f
473*2fe8fb19SBen Grasand
474*2fe8fb19SBen Gras.Cm %d
475*2fe8fb19SBen Grasare implicitly
476*2fe8fb19SBen Gras.Cm %512f
477*2fe8fb19SBen Grasand
478*2fe8fb19SBen Gras.Cm %512d .
479