1 .\" Copyright (c) 1990, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" This code is derived from software contributed to Berkeley by
5 .\" Chris Torek and the American National Standards Committee X3,
6 .\" on Information Processing Systems.
8 .\" Redistribution and use in source and binary forms, with or without
9 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
13 .\" 2. Redistributions in binary form must reproduce the above copyright
14 .\" notice, this list of conditions and the following disclaimer in the
15 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. All advertising materials mentioning features or use of this software
17 .\" must display the following acknowledgement:
18 .\" This product includes software developed by the University of
19 .\" California, Berkeley and its contributors.
20 .\" 4. Neither the name of the University nor the names of its contributors
21 .\" may be used to endorse or promote products derived from this software
22 .\" without specific prior written permission.
24 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 .\" @(#)scanf.3 8.2 (Berkeley) 12/11/93
37 .\" FreeBSD: src/lib/libc/stdio/scanf.3,v 1.24 2003/06/28 09:03:25 das Exp
38 .\" $FreeBSD: src/lib/libc/stdio/wscanf.3,v 1.6 2003/07/05 07:47:55 tjr Exp $
50 .Nd wide character input format conversion
57 .Fn wscanf "const wchar_t * restrict format" ...
59 .Fn fwscanf "FILE * restrict stream" "const wchar_t * restrict format" ...
61 .Fn swscanf "const wchar_t * restrict str" "const wchar_t * restrict format" ...
64 .Fn vwscanf "const wchar_t * restrict format" "va_list ap"
66 .Fn vswscanf "const wchar_t * restrict str" "const wchar_t * restrict format" "va_list ap"
68 .Fn vfwscanf "FILE * restrict stream" "const wchar_t * restrict format" "va_list ap"
72 family of functions scans input according to a
75 This format may contain
76 .Em conversion specifiers ;
77 the results from such conversions, if any,
78 are stored through the
84 reads input from the standard input stream
87 reads input from the stream pointer
91 reads its input from the wide character string pointed to by
98 and reads input from the stream pointer
100 using a variable argument list of pointers (see
104 function scans a variable argument list from the standard input and
107 function scans it from a wide character string;
108 these are analogous to
113 functions respectively.
116 argument must correspond properly with
117 each successive conversion specifier
121 All conversions are introduced by the
123 (percent sign) character.
127 may also contain other characters.
128 White space (such as blanks, tabs, or newlines) in the
130 string match any amount of white space, including none, in the input.
134 when an input character does not match such a format character.
136 when an input conversion cannot be made (see below).
140 character introducing a conversion
141 there may be a number of
143 characters, as follows:
144 .Bl -tag -width ".Cm l No (ell)"
146 Suppresses assignment.
147 The conversion that follows occurs as usual, but no pointer is used;
148 the result of the conversion is simply discarded.
150 Indicates that the conversion will be one of
154 and the next pointer is a pointer to a
159 Indicates that the conversion will be one of
163 and the next pointer is a pointer to a
168 Indicates that the conversion will be one of
172 and the next pointer is a pointer to a
176 that the conversion will be one of
180 and the next pointer is a pointer to
184 or that the conversion will be one of
188 and the next pointer is a pointer to an array of
192 .It Cm ll No (ell ell)
193 Indicates that the conversion will be one of
197 and the next pointer is a pointer to a
202 Indicates that the conversion will be one of
206 and the next pointer is a pointer to
209 Indicates that the conversion will be one of
213 and the next pointer is a pointer to a
218 Indicates that the conversion will be one of
222 and the next pointer is a pointer to a
227 Indicates that the conversion will be one of
231 and the next pointer is a pointer to a
237 Indicates that the conversion will be one of
241 and the next pointer is a pointer to a
247 In addition to these flags,
248 there may be an optional maximum field width,
249 expressed as a decimal integer,
253 If no width is given,
256 is used (with one exception, below);
257 otherwise at most this many characters are scanned
258 in processing the conversion.
259 Before conversion begins,
260 most conversions skip white space;
261 this white space is not counted against the field width.
263 The following conversions are available:
271 matches a single input
274 No conversion is done, and assignment does not occur.
276 Matches an optionally signed decimal integer;
277 the next pointer must be a pointer to
280 Matches an optionally signed integer;
281 the next pointer must be a pointer to
283 The integer is read in base 16 if it begins
288 in base 8 if it begins with
290 and in base 10 otherwise.
291 Only characters that correspond to the base are used.
293 Matches an octal integer;
294 the next pointer must be a pointer to
297 Matches an optionally signed decimal integer;
298 the next pointer must be a pointer to
301 Matches an optionally signed hexadecimal integer;
302 the next pointer must be a pointer to
304 .It Cm a , A , e , E , f , F , g , G
305 Matches a floating-point number in the style of
307 The next pointer must be a pointer to
315 Matches a sequence of non-white-space wide characters;
316 the next pointer must be a pointer to
318 and the array must be large enough to accept the multibyte representation
319 of all the sequence and the
323 The input string stops at white space
324 or at the maximum field width, whichever occurs first.
328 qualifier is present, the next pointer must be a pointer to
330 into which the input will be placed.
335 Matches a sequence of
338 wide characters (default 1);
339 the next pointer must be a pointer to
341 and there must be enough room for the multibyte representation
342 of all the characters
346 The usual skip of leading white space is suppressed.
347 To skip white space first, use an explicit space in the format.
351 qualifier is present, the next pointer must be a pointer to
353 into which the input will be placed.
358 Matches a nonempty sequence of characters from the specified set
359 of accepted characters;
360 the next pointer must be a pointer to
362 and there must be enough room for the multibyte representation of
363 all the characters in the string,
367 The usual skip of leading white space is suppressed.
368 The string is to be made up of characters in
371 the set is defined by the characters between the open bracket
380 if the first character after the open bracket is a circumflex
382 To include a close bracket in the set,
383 make it the first character after the open bracket
385 any other position will end the set.
386 To include a hyphen in the set,
387 make it the last character before the final close bracket;
388 some implementations of
392 to represent the range of characters between
396 The string ends with the appearance of a character not in the
397 (or, with a circumflex, in) set
398 or when the field width runs out.
402 qualifier is present, the next pointer must be a pointer to
404 into which the input will be placed.
406 Matches a pointer value (as printed by
410 the next pointer must be a pointer to
414 instead, the number of characters consumed thus far from the input
415 is stored through the next pointer,
416 which must be a pointer to
420 a conversion, although it can be suppressed with the
426 character is defined in the program's locale (category
429 For backwards compatibility, a
433 causes an immediate return of
439 the number of input items assigned, which can be fewer than provided
440 for, or even zero, in the event of a matching failure.
442 indicates that, while there was input available,
443 no conversions were assigned;
444 typically this is due to an invalid input character,
445 such as an alphabetic character for a
450 is returned if an input failure occurs before any conversion such as an
452 If an error or end-of-file occurs after conversion
454 the number of conversions which were successfully completed is returned.
476 In addition to the bugs documented in
481 notation for specifying character ranges with the character