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
58 .Fa "FILE *restrict stream"
59 .Fa "const wchar_t *restrict format"
64 .Fa "const wchar_t *restrict ws"
65 .Fa "const wchar_t *restrict format"
70 .Fa "const wchar_t *restrict format"
78 .Fa "FILE *restrict stream"
79 .Fa "const wchar_t *restrict format"
84 .Fa "const wchar_t *restrict ws"
85 .Fa "const wchar_t *restrict format"
90 .Fa "const wchar_t *restrict format"
96 family of functions scans input, according to a
99 This format may contain
100 .Em conversion specifiers ;
101 the results from such conversions, if any,
102 are stored through the
108 reads input from the standard input stream
111 reads input from the stream pointer
115 reads its input from the wide character string pointed to by
123 and reads input from the stream pointer
125 using a variable argument list of pointers (see
129 function scans a variable argument list from the standard input and
132 function scans it from a wide character string;
133 these are analogous to
138 functions respectively.
141 argument must correspond properly with
142 each successive conversion specifier
146 All conversions are introduced by the
148 (percent sign) character.
153 may also contain other characters.
154 White space (such as blanks, tabs, or newlines) in the
156 string match any amount of white space, including none, in the input.
160 when an input character does not match such a format character.
162 when an input conversion cannot be made (see below).
164 Extended locale versions of these functions are documented in
168 for more information.
172 character introducing a conversion,
173 there may be a number of
175 characters, as follows:
176 .Bl -tag -width ".Cm l No (ell)"
178 Suppresses assignment.
179 The conversion that follows occurs as usual, but no pointer is used;
180 the result of the conversion is simply discarded.
182 Indicates that the conversion will be one of
186 and the next pointer is a pointer to a
191 Indicates that the conversion will be one of
195 and the next pointer is a pointer to a
200 Indicates that the conversion will be one of
204 and the next pointer is a pointer to a
208 that the conversion will be one of
212 and the next pointer is a pointer to
216 or that the conversion will be one of
220 and the next pointer is a pointer to an array of
224 .It Cm ll No (ell ell)
225 Indicates that the conversion will be one of
229 and the next pointer is a pointer to a
234 Indicates that the conversion will be one of
238 and the next pointer is a pointer to
241 Indicates that the conversion will be one of
245 and the next pointer is a pointer to a
250 Indicates that the conversion will be one of
254 and the next pointer is a pointer to a
259 Indicates that the conversion will be one of
263 and the next pointer is a pointer to a
269 Indicates that the conversion will be one of
273 and the next pointer is a pointer to a
279 In addition to these flags,
280 there may be an optional maximum field width,
281 expressed as a decimal integer,
285 If no width is given,
288 is used (with one exception, below);
289 otherwise at most this many characters are scanned
290 in processing the conversion.
291 Before conversion begins,
292 most conversions skip white space;
293 this white space is not counted against the field width.
295 The following conversions are available:
303 matches a single input
306 No conversion is done, and assignment does not occur.
308 Matches an optionally signed decimal integer;
309 the next pointer must be a pointer to
312 Matches an optionally signed integer;
313 the next pointer must be a pointer to
315 The integer is read in base 16 if it begins
320 in base 8 if it begins with
322 and in base 10 otherwise.
323 Only characters that correspond to the base are used.
325 Matches an octal integer;
326 the next pointer must be a pointer to
329 Matches an optionally signed decimal integer;
330 the next pointer must be a pointer to
333 Matches an optionally signed hexadecimal integer;
334 the next pointer must be a pointer to
336 .It Cm a , A , e , E , f , F , g , G
337 Matches a floating-point number in the style of
339 The next pointer must be a pointer to
347 Matches a sequence of non-white-space wide characters;
348 the next pointer must be a pointer to
350 and the array must be large enough to accept the multibyte representation
351 of all the sequence and the
355 The input string stops at white space
356 or at the maximum field width, whichever occurs first.
360 qualifier is present, the next pointer must be a pointer to
362 into which the input will be placed.
367 Matches a sequence of
370 wide characters (default 1);
371 the next pointer must be a pointer to
373 and there must be enough room for the multibyte representation
374 of all the characters
378 The usual skip of leading white space is suppressed.
379 To skip white space first, use an explicit space in the format.
383 qualifier is present, the next pointer must be a pointer to
385 into which the input will be placed.
390 Matches a nonempty sequence of characters from the specified set
391 of accepted characters;
392 the next pointer must be a pointer to
394 and there must be enough room for the multibyte representation of
395 all the characters in the string,
399 The usual skip of leading white space is suppressed.
400 The string is to be made up of characters in
403 the set is defined by the characters between the open bracket
412 if the first character after the open bracket is a circumflex
414 To include a close bracket in the set,
415 make it the first character after the open bracket
417 any other position will end the set.
418 To include a hyphen in the set,
419 make it the last character before the final close bracket;
420 some implementations of
424 to represent the range of characters between
428 The string ends with the appearance of a character not in the
429 (or, with a circumflex, in) set
430 or when the field width runs out.
434 qualifier is present, the next pointer must be a pointer to
436 into which the input will be placed.
438 Matches a pointer value (as printed by
442 the next pointer must be a pointer to
446 instead, the number of characters consumed thus far from the input
447 is stored through the next pointer,
448 which must be a pointer to
452 a conversion, although it can be suppressed with the
458 character is defined in the program's locale (category
461 For backwards compatibility, a
465 causes an immediate return of
468 These functions return the number of input items assigned,
469 which can be fewer than provided for, or even zero,
470 in the event of a matching failure.
471 Zero indicates that, while there was input available,
472 no conversions were assigned;
473 typically, this is due to an invalid input character,
474 such as an alphabetic character for a
479 is returned if an input failure occurs before any conversion such as an
481 If an error or end-of-file occurs after conversion
483 the number of conversions which were successfully completed is returned.
506 In addition to the bugs documented in
511 notation for specifying character ranges with the character