]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright (c) 1990, 1991 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
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. | |
7 | .\" | |
a9cd9cb7 | 8 | .\" %%%LICENSE_START(BSD_4_CLAUSE_UCB) |
fea681da MK |
9 | .\" Redistribution and use in source and binary forms, with or without |
10 | .\" modification, are permitted provided that the following conditions | |
11 | .\" are met: | |
12 | .\" 1. Redistributions of source code must retain the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer. | |
14 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
15 | .\" notice, this list of conditions and the following disclaimer in the | |
16 | .\" documentation and/or other materials provided with the distribution. | |
17 | .\" 3. All advertising materials mentioning features or use of this software | |
18 | .\" must display the following acknowledgement: | |
19 | .\" This product includes software developed by the University of | |
20 | .\" California, Berkeley and its contributors. | |
21 | .\" 4. Neither the name of the University nor the names of its contributors | |
22 | .\" may be used to endorse or promote products derived from this software | |
23 | .\" without specific prior written permission. | |
24 | .\" | |
25 | .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
26 | .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
27 | .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
28 | .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
29 | .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
30 | .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
31 | .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
32 | .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
33 | .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
34 | .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
35 | .\" SUCH DAMAGE. | |
8c9302dc | 36 | .\" %%%LICENSE_END |
fea681da MK |
37 | .\" |
38 | .\" @(#)scanf.3 6.14 (Berkeley) 1/8/93 | |
39 | .\" | |
40 | .\" Converted for Linux, Mon Nov 29 15:22:01 1993, faith@cs.unc.edu | |
c13182ef | 41 | .\" modified to resemble the GNU libio setup used in the Linux libc |
fea681da MK |
42 | .\" used in versions 4.x (x>4) and 5 Helmut.Geyer@iwr.uni-heidelberg.de |
43 | .\" Modified, aeb, 970121 | |
c13182ef MK |
44 | .\" 2005-07-14, mtk, added description of %n$ form; various text |
45 | .\" incorporated from the GNU C library documentation ((C) The | |
991910a4 | 46 | .\" Free Software Foundation); other parts substantially rewritten. |
fea681da | 47 | .\" |
7042009b | 48 | .\" 2008-06-23, mtk |
194f4ccb MK |
49 | .\" Add ERRORS section. |
50 | .\" Document the 'a' and 'm' modifiers for dynamic string allocation. | |
7deb3c8b | 51 | .\" |
4b8c67d9 | 52 | .TH SCANF 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
fea681da MK |
53 | .SH NAME |
54 | scanf, fscanf, sscanf, vscanf, vsscanf, vfscanf \- input format conversion | |
55 | .SH SYNOPSIS | |
56 | .nf | |
57 | .B #include <stdio.h> | |
f90f031e | 58 | .PP |
a45ebabf MK |
59 | .BI "int scanf(const char *" format ", ...);" |
60 | .BI "int fscanf(FILE *" stream ", const char *" format ", ...);" | |
61 | .BI "int sscanf(const char *" str ", const char *" format ", ...);" | |
a45ebabf | 62 | |
f90f031e MK |
63 | .B #include <stdarg.h> |
64 | .PP | |
fea681da | 65 | .BI "int vscanf(const char *" format ", va_list " ap ); |
fea681da | 66 | .BI "int vsscanf(const char *" str ", const char *" format ", va_list " ap ); |
fea681da | 67 | .BI "int vfscanf(FILE *" stream ", const char *" format ", va_list " ap ); |
cc4615cc | 68 | .fi |
68e4db0a | 69 | .PP |
cc4615cc MK |
70 | .in -4n |
71 | Feature Test Macro Requirements for glibc (see | |
72 | .BR feature_test_macros (7)): | |
73 | .in | |
a1d525f2 | 74 | .ad l |
68e4db0a | 75 | .PP |
cc4615cc MK |
76 | .BR vscanf (), |
77 | .BR vsscanf (), | |
78 | .BR vfscanf (): | |
a1d525f2 | 79 | .RS 4 |
e464f054 | 80 | _ISOC99_SOURCE || _POSIX_C_SOURCE\ >=\ 200112L |
a1d525f2 MK |
81 | .ad |
82 | .RE | |
fea681da MK |
83 | .SH DESCRIPTION |
84 | The | |
e511ffb6 | 85 | .BR scanf () |
991910a4 | 86 | family of functions scans input according to |
fea681da | 87 | .I format |
c13182ef MK |
88 | as described below. |
89 | This format may contain | |
991910a4 MK |
90 | .IR "conversion specifications" ; |
91 | the results from such conversions, if any, | |
92 | are stored in the locations pointed to by the | |
c13182ef | 93 | .I pointer |
991910a4 MK |
94 | arguments that follow |
95 | .IR format . | |
c13182ef | 96 | Each |
fea681da | 97 | .I pointer |
c13182ef | 98 | argument must be of a type that is appropriate for the value returned |
991910a4 | 99 | by the corresponding conversion specification. |
847e0d88 | 100 | .PP |
991910a4 MK |
101 | If the number of conversion specifications in |
102 | .I format | |
103 | exceeds the number of | |
104 | .I pointer | |
105 | arguments, the results are undefined. | |
106 | If the number of | |
107 | .I pointer | |
108 | arguments exceeds the number of conversion specifications, then the excess | |
109 | .I pointer | |
110 | arguments are evaluated, but are otherwise ignored. | |
847e0d88 | 111 | .PP |
991910a4 | 112 | The |
e511ffb6 | 113 | .BR scanf () |
fea681da MK |
114 | function reads input from the standard input stream |
115 | .IR stdin , | |
e511ffb6 | 116 | .BR fscanf () |
fea681da MK |
117 | reads input from the stream pointer |
118 | .IR stream , | |
119 | and | |
e511ffb6 | 120 | .BR sscanf () |
fea681da MK |
121 | reads its input from the character string pointed to by |
122 | .IR str . | |
123 | .PP | |
124 | The | |
e511ffb6 | 125 | .BR vfscanf () |
fea681da MK |
126 | function is analogous to |
127 | .BR vfprintf (3) | |
128 | and reads input from the stream pointer | |
129 | .I stream | |
130 | using a variable argument list of pointers (see | |
131 | .BR stdarg (3). | |
132 | The | |
e511ffb6 | 133 | .BR vscanf () |
fea681da | 134 | function scans a variable argument list from the standard input and the |
e511ffb6 | 135 | .BR vsscanf () |
fea681da | 136 | function scans it from a string; these are analogous to the |
fb186734 | 137 | .BR vprintf (3) |
fea681da | 138 | and |
fb186734 | 139 | .BR vsprintf (3) |
fea681da MK |
140 | functions respectively. |
141 | .PP | |
991910a4 MK |
142 | The |
143 | .I format | |
c13182ef | 144 | string consists of a sequence of |
0daa9e92 | 145 | .I directives |
991910a4 MK |
146 | which describe how to process the sequence of input characters. |
147 | If processing of a directive fails, no further input is read, and | |
e511ffb6 | 148 | .BR scanf () |
991910a4 MK |
149 | returns. |
150 | A "failure" can be either of the following: | |
151 | .IR "input failure" , | |
152 | meaning that input characters were unavailable, or | |
153 | .IR "matching failure" , | |
154 | meaning that the input was inappropriate (see below). | |
847e0d88 | 155 | .PP |
991910a4 MK |
156 | A directive is one of the following: |
157 | .TP | |
158 | \(bu | |
0967c11f | 159 | A sequence of white-space characters (space, tab, newline, etc.; see |
991910a4 MK |
160 | .BR isspace (3)). |
161 | This directive matches any amount of white space, | |
162 | including none, in the input. | |
163 | .TP | |
164 | \(bu | |
333a424b | 165 | An ordinary character (i.e., one other than white space or \(aq%\(aq). |
991910a4 MK |
166 | This character must exactly match the next character of input. |
167 | .TP | |
168 | \(bu | |
333a424b MK |
169 | A conversion specification, |
170 | which commences with a \(aq%\(aq (percent) character. | |
c13182ef | 171 | A sequence of characters from the input is converted according to |
991910a4 | 172 | this specification, and the result is placed in the corresponding |
fea681da | 173 | .I pointer |
991910a4 | 174 | argument. |
8666f209 | 175 | If the next item of input does not match the conversion specification, |
5503c85e | 176 | the conversion fails\(emthis is a |
991910a4 MK |
177 | .IR "matching failure" . |
178 | .PP | |
179 | Each | |
c13182ef | 180 | .I conversion specification |
991910a4 | 181 | in |
c13182ef | 182 | .I format |
333a424b | 183 | begins with either the character \(aq%\(aq or the character sequence |
991910a4 | 184 | "\fB%\fP\fIn\fP\fB$\fP" |
faa42a0a | 185 | (see below for the distinction) followed by: |
991910a4 MK |
186 | .TP |
187 | \(bu | |
333a424b | 188 | An optional \(aq*\(aq assignment-suppression character: |
e511ffb6 | 189 | .BR scanf () |
991910a4 MK |
190 | reads input as directed by the conversion specification, |
191 | but discards the input. | |
192 | No corresponding | |
193 | .I pointer | |
194 | argument is required, and this specification is not | |
195 | included in the count of successful assignments returned by | |
e511ffb6 | 196 | .BR scanf (). |
991910a4 MK |
197 | .TP |
198 | \(bu | |
b59a4ee7 MK |
199 | For decimal conversions, an optional quote character (\(aq). |
200 | This specifies that the input number may include thousands' | |
201 | separators as defined by the | |
202 | .BR LC_NUMERIC | |
203 | category of the current locale. | |
204 | (See | |
205 | .BR setlocale (3).) | |
206 | The quote character may precede or follow the \(aq*\(aq | |
207 | assignment-suppression character. | |
208 | .TP | |
209 | \(bu | |
71380e9e | 210 | An optional \(aqm\(aq character. |
558fe164 MK |
211 | This is used with string conversions |
212 | .RI ( %s , | |
213 | .IR %c , | |
214 | .IR %[ ), | |
215 | and relieves the caller of the | |
991910a4 | 216 | need to allocate a corresponding buffer to hold the input: instead, |
e511ffb6 | 217 | .BR scanf () |
c13182ef | 218 | allocates a buffer of sufficient size, |
991910a4 MK |
219 | and assigns the address of this buffer to the corresponding |
220 | .I pointer | |
221 | argument, which should be a pointer to a | |
5049da5b | 222 | .I "char\ *" |
d9bfdb9c | 223 | variable (this variable does not need to be initialized before the call). |
991910a4 MK |
224 | The caller should subsequently |
225 | .BR free (3) | |
226 | this buffer when it is no longer required. | |
991910a4 MK |
227 | .TP |
228 | \(bu | |
229 | An optional decimal integer which specifies the | |
230 | .IR "maximum field width" . | |
c13182ef | 231 | Reading of characters stops either when this maximum is reached or |
24b74457 | 232 | when a nonmatching character is found, whichever happens first. |
f9d17bc4 | 233 | Most conversions discard initial white space characters (the exceptions |
c13182ef | 234 | are noted below), |
5fab2e7c | 235 | and these discarded characters don't count toward the maximum field width. |
71d9e7ae | 236 | String input conversions store a terminating null byte (\(aq\\0\(aq) |
c13182ef | 237 | to mark the end of the input; |
991910a4 MK |
238 | the maximum field width does not include this terminator. |
239 | .TP | |
240 | \(bu | |
c13182ef MK |
241 | An optional |
242 | .IR "type modifier character" . | |
991910a4 MK |
243 | For example, the |
244 | .B l | |
c13182ef | 245 | type modifier is used with integer conversions such as |
5adafd6d | 246 | .B %d |
991910a4 MK |
247 | to specify that the corresponding |
248 | .I pointer | |
c13182ef | 249 | argument refers to a |
991910a4 | 250 | .I "long int" |
c13182ef | 251 | rather than a pointer to an |
991910a4 MK |
252 | .IR int . |
253 | .TP | |
254 | \(bu | |
c13182ef | 255 | A |
991910a4 MK |
256 | .I "conversion specifier" |
257 | that specifies the type of input conversion to be performed. | |
c13182ef | 258 | .PP |
991910a4 | 259 | The conversion specifications in |
fea681da | 260 | .I format |
333a424b | 261 | are of two forms, either beginning with \(aq%\(aq or beginning with |
991910a4 | 262 | "\fB%\fP\fIn\fP\fB$\fP". |
c13182ef | 263 | The two forms should not be mixed in the same |
fea681da | 264 | .I format |
c13182ef | 265 | string, except that a string containing |
991910a4 MK |
266 | "\fB%\fP\fIn\fP\fB$\fP" |
267 | specifications can include | |
5adafd6d | 268 | .B %% |
c13182ef | 269 | and |
5adafd6d | 270 | .BR %* . |
991910a4 MK |
271 | If |
272 | .I format | |
333a424b | 273 | contains \(aq%\(aq |
830b5761 | 274 | specifications, then these correspond in order with successive |
991910a4 MK |
275 | .I pointer |
276 | arguments. | |
277 | In the | |
278 | "\fB%\fP\fIn\fP\fB$\fP" | |
68e1685c | 279 | form (which is specified in POSIX.1-2001, but not C99), |
991910a4 | 280 | .I n |
c13182ef | 281 | is a decimal integer that specifies that the converted input should |
991910a4 MK |
282 | be placed in the location referred to by the |
283 | .IR n -th | |
284 | .I pointer | |
285 | argument following | |
286 | .IR format . | |
8af1ba10 | 287 | .SS Conversions |
991910a4 | 288 | The following |
0daa9e92 | 289 | .I "type modifier characters" |
991910a4 | 290 | can appear in a conversion specification: |
fea681da MK |
291 | .TP |
292 | .B h | |
293 | Indicates that the conversion will be one of | |
c59f8dfe | 294 | \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP, \fBX\fP, or \fBn\fP |
fea681da | 295 | and the next pointer is a pointer to a |
991910a4 MK |
296 | .I short int |
297 | or | |
298 | .I unsigned short int | |
fea681da MK |
299 | (rather than |
300 | .IR int ). | |
301 | .TP | |
991910a4 MK |
302 | .B hh |
303 | As for | |
304 | .BR h , | |
305 | but the next pointer is a pointer to a | |
306 | .I signed char | |
307 | or | |
308 | .IR "unsigned char" . | |
309 | .TP | |
310 | .B j | |
311 | As for | |
312 | .BR h , | |
3c5e62b6 | 313 | but the next pointer is a pointer to an |
991910a4 | 314 | .I intmax_t |
3c5e62b6 | 315 | or a |
991910a4 MK |
316 | .IR uintmax_t . |
317 | This modifier was introduced in C99. | |
318 | .TP | |
fea681da MK |
319 | .B l |
320 | Indicates either that the conversion will be one of | |
c59f8dfe | 321 | \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, \fBx\fP, \fBX\fP, or \fBn\fP |
fea681da | 322 | and the next pointer is a pointer to a |
991910a4 MK |
323 | .I long int |
324 | or | |
325 | .I unsigned long int | |
fea681da MK |
326 | (rather than |
327 | .IR int ), | |
328 | or that the conversion will be one of | |
c59f8dfe | 329 | \fBe\fP, \fBf\fP, or \fBg\fP |
fea681da MK |
330 | and the next pointer is a pointer to |
331 | .I double | |
332 | (rather than | |
333 | .IR float ). | |
c13182ef | 334 | Specifying two |
fea681da | 335 | .B l |
991910a4 MK |
336 | characters is equivalent to |
337 | .BR L . | |
338 | If used with | |
5adafd6d | 339 | .B %c |
c13182ef | 340 | or |
53df4e93 | 341 | .BR %s , |
c13182ef | 342 | the corresponding parameter is considered |
d0f17b57 | 343 | as a pointer to a wide character or wide-character string respectively. |
991910a4 | 344 | .\" This use of l was introduced in Amendment 1 to ISO C90. |
fea681da MK |
345 | .TP |
346 | .B L | |
347 | Indicates that the conversion will be either | |
c59f8dfe | 348 | \fBe\fP, \fBf\fP, or \fBg\fP |
fea681da | 349 | and the next pointer is a pointer to |
0daa9e92 | 350 | .I "long double" |
c13182ef | 351 | or the conversion will be |
c59f8dfe | 352 | \fBd\fP, \fBi\fP, \fBo\fP, \fBu\fP, or \fBx\fP |
fea681da MK |
353 | and the next pointer is a pointer to |
354 | .IR "long long" . | |
c13182ef | 355 | .\" MTK, Jul 05: The following is no longer true for modern |
991910a4 | 356 | .\" ANSI C (i.e., C99): |
c13182ef MK |
357 | .\" (Note that long long is not an |
358 | .\" ANSI C | |
991910a4 MK |
359 | .\" type. Any program using this will not be portable to all |
360 | .\" architectures). | |
fea681da MK |
361 | .TP |
362 | .B q | |
c13182ef MK |
363 | equivalent to |
364 | .BR L . | |
991910a4 MK |
365 | This specifier does not exist in ANSI C. |
366 | .TP | |
367 | .B t | |
368 | As for | |
369 | .BR h , | |
370 | but the next pointer is a pointer to a | |
371 | .IR ptrdiff_t . | |
372 | This modifier was introduced in C99. | |
373 | .TP | |
374 | .B z | |
375 | As for | |
376 | .BR h , | |
377 | but the next pointer is a pointer to a | |
378 | .IR size_t . | |
379 | This modifier was introduced in C99. | |
fea681da | 380 | .PP |
c13182ef | 381 | The following |
991910a4 MK |
382 | .I "conversion specifiers" |
383 | are available: | |
fea681da MK |
384 | .TP |
385 | .B % | |
333a424b | 386 | Matches a literal \(aq%\(aq. |
c13182ef | 387 | That is, |
5adafd6d | 388 | .B %\&% |
991910a4 | 389 | in the format string matches a |
333a424b | 390 | single input \(aq%\(aq character. |
f9d17bc4 MK |
391 | No conversion is done (but initial white space characters are discarded), |
392 | and assignment does not occur. | |
fea681da MK |
393 | .TP |
394 | .B d | |
395 | Matches an optionally signed decimal integer; | |
396 | the next pointer must be a pointer to | |
397 | .IR int . | |
398 | .TP | |
399 | .B D | |
400 | Equivalent to | |
991910a4 | 401 | .IR ld ; |
5fab2e7c | 402 | this exists only for backward compatibility. |
c13182ef MK |
403 | (Note: thus only in libc4. |
404 | In libc5 and glibc the | |
5adafd6d | 405 | .B %D |
991910a4 | 406 | is silently ignored, causing old programs to fail mysteriously.) |
fea681da MK |
407 | .TP |
408 | .B i | |
409 | Matches an optionally signed integer; the next pointer must be a pointer to | |
410 | .IR int . | |
c13182ef | 411 | The integer is read in base 16 if it begins with |
991910a4 | 412 | .I 0x |
c13182ef MK |
413 | or |
414 | .IR 0X , | |
415 | in base 8 if it begins with | |
416 | .IR 0 , | |
991910a4 MK |
417 | and in base 10 otherwise. |
418 | Only characters that correspond to the base are used. | |
fea681da MK |
419 | .TP |
420 | .B o | |
421 | Matches an unsigned octal integer; the next pointer must be a pointer to | |
422 | .IR "unsigned int" . | |
423 | .TP | |
424 | .B u | |
425 | Matches an unsigned decimal integer; the next pointer must be a | |
426 | pointer to | |
427 | .IR "unsigned int" . | |
428 | .TP | |
429 | .B x | |
430 | Matches an unsigned hexadecimal integer; the next pointer must | |
431 | be a pointer to | |
432 | .IR "unsigned int" . | |
433 | .TP | |
434 | .B X | |
435 | Equivalent to | |
436 | .BR x . | |
437 | .TP | |
438 | .B f | |
439 | Matches an optionally signed floating-point number; the next pointer must | |
440 | be a pointer to | |
441 | .IR float . | |
442 | .TP | |
443 | .B e | |
444 | Equivalent to | |
445 | .BR f . | |
446 | .TP | |
447 | .B g | |
448 | Equivalent to | |
449 | .BR f . | |
450 | .TP | |
451 | .B E | |
452 | Equivalent to | |
453 | .BR f . | |
454 | .TP | |
991910a4 MK |
455 | .B a |
456 | (C99) Equivalent to | |
457 | .BR f . | |
458 | .TP | |
fea681da | 459 | .B s |
991910a4 | 460 | Matches a sequence of non-white-space characters; |
dd1d112d MK |
461 | the next pointer must be a pointer to the initial element of a |
462 | character array that is long enough to hold the input sequence and | |
71d9e7ae | 463 | the terminating null byte (\(aq\\0\(aq), which is added automatically. |
991910a4 | 464 | The input string stops at white space or at the maximum field |
fea681da MK |
465 | width, whichever occurs first. |
466 | .TP | |
467 | .B c | |
991910a4 MK |
468 | Matches a sequence of characters whose length is specified by the |
469 | .I maximum field width | |
470 | (default 1); the next pointer must be a pointer to | |
fea681da | 471 | .IR char , |
0a5d2e21 MK |
472 | and there must be enough room for all the characters |
473 | (no terminating null byte is added). | |
c13182ef MK |
474 | The usual skip of leading white space is suppressed. |
475 | To skip white space first, use an explicit space in the format. | |
fea681da MK |
476 | .TP |
477 | .B \&[ | |
aa796481 | 478 | Matches a nonempty sequence of characters from the specified set of |
fea681da MK |
479 | accepted characters; the next pointer must be a pointer to |
480 | .IR char , | |
481 | and there must be enough room for all the characters in the string, plus a | |
28d88c17 | 482 | terminating null byte. |
c13182ef MK |
483 | The usual skip of leading white space is suppressed. |
484 | The string is to be made up of characters in (or not in) a particular set; | |
485 | the set is defined by the characters between the open bracket | |
fea681da MK |
486 | .B [ |
487 | character and a close bracket | |
488 | .B ] | |
c13182ef MK |
489 | character. |
490 | The set | |
fea681da MK |
491 | .I excludes |
492 | those characters if the first character after the open bracket is a | |
493 | circumflex | |
43daf87d | 494 | .RB ( ^ ). |
fea681da MK |
495 | To include a close bracket in the set, make it the first character after |
496 | the open bracket or the circumflex; any other position will end the set. | |
497 | The hyphen character | |
8c383102 | 498 | .B \- |
fea681da | 499 | is also special; when placed between two other characters, it adds all |
c13182ef MK |
500 | intervening characters to the set. |
501 | To include a hyphen, make it the last | |
502 | character before the final close bracket. | |
503 | For instance, | |
34131745 | 504 | .B [^]0\-9\-] |
991910a4 MK |
505 | means |
506 | the set "everything except close bracket, zero through nine, and hyphen". | |
fea681da MK |
507 | The string ends with the appearance of a character not in the (or, with a |
508 | circumflex, in) set or when the field width runs out. | |
509 | .TP | |
510 | .B p | |
c13182ef | 511 | Matches a pointer value (as printed by |
5adafd6d | 512 | .B %p |
991910a4 | 513 | in |
fea681da | 514 | .BR printf (3); |
475f1bca | 515 | the next pointer must be a pointer to a pointer to |
fea681da MK |
516 | .IR void . |
517 | .TP | |
518 | .B n | |
519 | Nothing is expected; instead, the number of characters consumed thus far | |
520 | from the input is stored through the next pointer, which must be a pointer | |
521 | to | |
522 | .IR int . | |
523 | This is | |
524 | .I not | |
93c2e069 JH |
525 | a conversion and does |
526 | .I not | |
527 | increase the count returned by the function. | |
528 | The assignment can be suppressed with the | |
fea681da | 529 | .B * |
93c2e069 JH |
530 | assignment-suppression character, but the effect on the |
531 | return value is undefined. | |
532 | Therefore | |
533 | .B %*n | |
534 | conversions should not be used. | |
47297adb | 535 | .SH RETURN VALUE |
ea112750 MK |
536 | On success, these functions return the number of input items |
537 | successfully matched and assigned; | |
538 | this can be fewer than provided for, | |
539 | or even zero, in the event of an early matching failure. | |
847e0d88 | 540 | .PP |
4d9b6984 MK |
541 | The value |
542 | .B EOF | |
c13182ef | 543 | is returned if the end of input is reached before either the first |
6e888f06 | 544 | successful conversion or a matching failure occurs. |
fea681da | 545 | .B EOF |
c13182ef | 546 | is also returned if a read error occurs, |
4d9b6984 MK |
547 | in which case the error indicator for the stream (see |
548 | .BR ferror (3)) | |
549 | is set, and | |
550 | .I errno | |
9e3f236d | 551 | is set to indicate the error. |
646af540 | 552 | .SH ERRORS |