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 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)scanf.3 8.2 (Berkeley) 12/11/93
33 .\" FreeBSD: src/lib/libc/stdio/scanf.3,v 1.24 2003/06/28 09:03:25 das Exp
34 .\" $FreeBSD: src/lib/libc/stdio/wscanf.3,v 1.7 2007/01/09 00:28:08 imp Exp $
46 .Nd wide character input format conversion
54 .Fa "FILE *restrict stream"
55 .Fa "const wchar_t *restrict format"
60 .Fa "const wchar_t *restrict ws"
61 .Fa "const wchar_t *restrict format"
66 .Fa "const wchar_t *restrict format"
74 .Fa "FILE *restrict stream"
75 .Fa "const wchar_t *restrict format"
80 .Fa "const wchar_t *restrict ws"
81 .Fa "const wchar_t *restrict format"
86 .Fa "const wchar_t *restrict format"
92 family of functions scans input, according to a
95 This format may contain
96 .Em conversion specifiers ;
97 the results from such conversions, if any,
98 are stored through the
104 reads input from the standard input stream
107 reads input from the stream pointer
111 reads its input from the wide character string pointed to by
119 and reads input from the stream pointer
121 using a variable argument list of pointers (see
125 function scans a variable argument list from the standard input and
128 function scans it from a wide character string;
129 these are analogous to
134 functions respectively.
137 argument must correspond properly with
138 each successive conversion specifier
142 All conversions are introduced by the
144 (percent sign) character.
149 may also contain other characters.
150 White space (such as blanks, tabs, or newlines) in the
152 string match any amount of white space, including none, in the input.
156 when an input character does not match such a format character.
158 when an input conversion cannot be made (see below).
160 Extended locale versions of these functions are documented in
164 for more information.
168 character introducing a conversion,
169 there may be a number of
171 characters, as follows:
172 .Bl -tag -width ".Cm l No (ell)"
174 Suppresses assignment.
175 The conversion that follows occurs as usual, but no pointer is used;
176 the result of the conversion is simply discarded.
178 Indicates that the conversion will be one of
182 and the next pointer is a pointer to a
187 Indicates that the conversion will be one of
191 and the next pointer is a pointer to a
196 Indicates that the conversion will be one of
200 and the next pointer is a pointer to a
204 that the conversion will be one of
208 and the next pointer is a pointer to
212 or that the conversion will be one of
216 and the next pointer is a pointer to an array of
220 .It Cm ll No (ell ell)
221 Indicates that the conversion will be one of
225 and the next pointer is a pointer to a
230 Indicates that the conversion will be one of
234 and the next pointer is a pointer to
237 Indicates that the conversion will be one of
241 and the next pointer is a pointer to a
246 Indicates that the conversion will be one of
250 and the next pointer is a pointer to a
255 Indicates that the conversion will be one of
259 and the next pointer is a pointer to a
265 Indicates that the conversion will be one of
269 and the next pointer is a pointer to a
275 In addition to these flags,
276 there may be an optional maximum field width,
277 expressed as a decimal integer,
281 If no width is given,
284 is used (with one exception, below);
285 otherwise at most this many characters are scanned
286 in processing the conversion.
287 Before conversion begins,
288 most conversions skip white space;
289 this white space is not counted against the field width.
291 The following conversions are available:
299 matches a single input
302 No conversion is done, and assignment does not occur.
304 Matches an optionally signed decimal integer;
305 the next pointer must be a pointer to
308 Matches an optionally signed integer;
309 the next pointer must be a pointer to
311 The integer is read in base 16 if it begins
316 in base 8 if it begins with
318 and in base 10 otherwise.
319 Only characters that correspond to the base are used.
321 Matches an octal integer;
322 the next pointer must be a pointer to
325 Matches an optionally signed decimal integer;
326 the next pointer must be a pointer to
329 Matches an optionally signed hexadecimal integer;
330 the next pointer must be a pointer to
332 .It Cm a , A , e , E , f , F , g , G
333 Matches a floating-point number in the style of
335 The next pointer must be a pointer to
343 Matches a sequence of non-white-space wide characters;
344 the next pointer must be a pointer to
346 and the array must be large enough to accept the multibyte representation
347 of all the sequence and the
351 The input string stops at white space
352 or at the maximum field width, whichever occurs first.
356 qualifier is present, the next pointer must be a pointer to
358 into which the input will be placed.
363 Matches a sequence of
366 wide characters (default 1);
367 the next pointer must be a pointer to
369 and there must be enough room for the multibyte representation
370 of all the characters
374 The usual skip of leading white space is suppressed.
375 To skip white space first, use an explicit space in the format.
379 qualifier is present, the next pointer must be a pointer to
381 into which the input will be placed.
386 Matches a nonempty sequence of characters from the specified set
387 of accepted characters;
388 the next pointer must be a pointer to
390 and there must be enough room for the multibyte representation of
391 all the characters in the string,
395 The usual skip of leading white space is suppressed.
396 The string is to be made up of characters in
399 the set is defined by the characters between the open bracket
408 if the first character after the open bracket is a circumflex
410 To include a close bracket in the set,
411 make it the first character after the open bracket
413 any other position will end the set.
414 To include a hyphen in the set,
415 make it the last character before the final close bracket;
416 some implementations of
420 to represent the range of characters between
424 The string ends with the appearance of a character not in the
425 (or, with a circumflex, in) set
426 or when the field width runs out.
430 qualifier is present, the next pointer must be a pointer to
432 into which the input will be placed.
434 Matches a pointer value (as printed by
438 the next pointer must be a pointer to
442 instead, the number of characters consumed thus far from the input
443 is stored through the next pointer,
444 which must be a pointer to
448 a conversion, although it can be suppressed with the
454 character is defined in the program's locale (category
457 For backwards compatibility, a
461 causes an immediate return of
464 These functions return the number of input items assigned,
465 which can be fewer than provided for, or even zero,
466 in the event of a matching failure.
467 Zero indicates that, while there was input available,
468 no conversions were assigned;
469 typically, this is due to an invalid input character,
470 such as an alphabetic character for a
475 is returned if an input failure occurs before any conversion such as an
477 If an error or end-of-file occurs after conversion
479 the number of conversions which were successfully completed is returned.
502 In addition to the bugs documented in
507 notation for specifying character ranges with the character