158f0484fSRodney W. Grimes.\" Copyright (c) 1990, 1991, 1993 258f0484fSRodney W. Grimes.\" The Regents of the University of California. All rights reserved. 358f0484fSRodney W. Grimes.\" 458f0484fSRodney W. Grimes.\" This code is derived from software contributed to Berkeley by 558f0484fSRodney W. Grimes.\" Chris Torek and the American National Standards Committee X3, 658f0484fSRodney W. Grimes.\" on Information Processing Systems. 758f0484fSRodney W. Grimes.\" 858f0484fSRodney W. Grimes.\" Redistribution and use in source and binary forms, with or without 958f0484fSRodney W. Grimes.\" modification, are permitted provided that the following conditions 1058f0484fSRodney W. Grimes.\" are met: 1158f0484fSRodney W. Grimes.\" 1. Redistributions of source code must retain the above copyright 1258f0484fSRodney W. Grimes.\" notice, this list of conditions and the following disclaimer. 1358f0484fSRodney W. Grimes.\" 2. Redistributions in binary form must reproduce the above copyright 1458f0484fSRodney W. Grimes.\" notice, this list of conditions and the following disclaimer in the 1558f0484fSRodney W. Grimes.\" documentation and/or other materials provided with the distribution. 1658f0484fSRodney W. Grimes.\" 3. All advertising materials mentioning features or use of this software 1758f0484fSRodney W. Grimes.\" must display the following acknowledgement: 1858f0484fSRodney W. Grimes.\" This product includes software developed by the University of 1958f0484fSRodney W. Grimes.\" California, Berkeley and its contributors. 2058f0484fSRodney W. Grimes.\" 4. Neither the name of the University nor the names of its contributors 2158f0484fSRodney W. Grimes.\" may be used to endorse or promote products derived from this software 2258f0484fSRodney W. Grimes.\" without specific prior written permission. 2358f0484fSRodney W. Grimes.\" 2458f0484fSRodney W. Grimes.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2558f0484fSRodney W. Grimes.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2658f0484fSRodney W. Grimes.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2758f0484fSRodney W. Grimes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 2858f0484fSRodney W. Grimes.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2958f0484fSRodney W. Grimes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3058f0484fSRodney W. Grimes.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3158f0484fSRodney W. Grimes.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3258f0484fSRodney W. Grimes.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3358f0484fSRodney W. Grimes.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3458f0484fSRodney W. Grimes.\" SUCH DAMAGE. 3558f0484fSRodney W. Grimes.\" 3658f0484fSRodney W. Grimes.\" @(#)scanf.3 8.2 (Berkeley) 12/11/93 377f3dea24SPeter Wemm.\" $FreeBSD$ 3858f0484fSRodney W. Grimes.\" 39e2b090f3STim J. Robbins.Dd January 4, 2003 4058f0484fSRodney W. Grimes.Dt SCANF 3 4158f0484fSRodney W. Grimes.Os 4258f0484fSRodney W. Grimes.Sh NAME 4358f0484fSRodney W. Grimes.Nm scanf , 4458f0484fSRodney W. Grimes.Nm fscanf , 4558f0484fSRodney W. Grimes.Nm sscanf , 4658f0484fSRodney W. Grimes.Nm vscanf , 4758f0484fSRodney W. Grimes.Nm vsscanf , 4858f0484fSRodney W. Grimes.Nm vfscanf 4958f0484fSRodney W. Grimes.Nd input format conversion 5025bb73e0SAlexey Zelkin.Sh LIBRARY 5125bb73e0SAlexey Zelkin.Lb libc 5258f0484fSRodney W. Grimes.Sh SYNOPSIS 5332eef9aeSRuslan Ermilov.In stdio.h 5458f0484fSRodney W. Grimes.Ft int 5554e4e385SMike Barcroft.Fn scanf "const char * restrict format" ... 5658f0484fSRodney W. Grimes.Ft int 5754e4e385SMike Barcroft.Fn fscanf "FILE * restrict stream" "const char * restrict format" ... 5858f0484fSRodney W. Grimes.Ft int 5954e4e385SMike Barcroft.Fn sscanf "const char * restrict str" "const char * restrict format" ... 6032eef9aeSRuslan Ermilov.In stdarg.h 6158f0484fSRodney W. Grimes.Ft int 6254e4e385SMike Barcroft.Fn vscanf "const char * restrict format" "va_list ap" 6358f0484fSRodney W. Grimes.Ft int 6454e4e385SMike Barcroft.Fn vsscanf "const char * restrict str" "const char * restrict format" "va_list ap" 6558f0484fSRodney W. Grimes.Ft int 6654e4e385SMike Barcroft.Fn vfscanf "FILE * restrict stream" "const char * restrict format" "va_list ap" 6758f0484fSRodney W. Grimes.Sh DESCRIPTION 6858f0484fSRodney W. GrimesThe 6958f0484fSRodney W. Grimes.Fn scanf 7058f0484fSRodney W. Grimesfamily of functions scans input according to a 7158f0484fSRodney W. Grimes.Fa format 7258f0484fSRodney W. Grimesas described below. 7358f0484fSRodney W. GrimesThis format may contain 7458f0484fSRodney W. Grimes.Em conversion specifiers ; 7558f0484fSRodney W. Grimesthe results from such conversions, if any, 7658f0484fSRodney W. Grimesare stored through the 7758f0484fSRodney W. Grimes.Em pointer 7858f0484fSRodney W. Grimesarguments. 7958f0484fSRodney W. GrimesThe 8058f0484fSRodney W. Grimes.Fn scanf 8158f0484fSRodney W. Grimesfunction 8258f0484fSRodney W. Grimesreads input from the standard input stream 83ae828962SRuslan Ermilov.Dv stdin , 8458f0484fSRodney W. Grimes.Fn fscanf 8558f0484fSRodney W. Grimesreads input from the stream pointer 8658f0484fSRodney W. Grimes.Fa stream , 8758f0484fSRodney W. Grimesand 8858f0484fSRodney W. Grimes.Fn sscanf 8958f0484fSRodney W. Grimesreads its input from the character string pointed to by 9058f0484fSRodney W. Grimes.Fa str . 9158f0484fSRodney W. GrimesThe 9258f0484fSRodney W. Grimes.Fn vfscanf 9358f0484fSRodney W. Grimesfunction 9458f0484fSRodney W. Grimesis analogous to 9558f0484fSRodney W. Grimes.Xr vfprintf 3 9658f0484fSRodney W. Grimesand reads input from the stream pointer 9758f0484fSRodney W. Grimes.Fa stream 9858f0484fSRodney W. Grimesusing a variable argument list of pointers (see 9958f0484fSRodney W. Grimes.Xr stdarg 3 ) . 10058f0484fSRodney W. GrimesThe 10158f0484fSRodney W. Grimes.Fn vscanf 10258f0484fSRodney W. Grimesfunction scans a variable argument list from the standard input and 10358f0484fSRodney W. Grimesthe 10458f0484fSRodney W. Grimes.Fn vsscanf 10558f0484fSRodney W. Grimesfunction scans it from a string; 10658f0484fSRodney W. Grimesthese are analogous to 10758f0484fSRodney W. Grimesthe 10858f0484fSRodney W. Grimes.Fn vprintf 10958f0484fSRodney W. Grimesand 11058f0484fSRodney W. Grimes.Fn vsprintf 11158f0484fSRodney W. Grimesfunctions respectively. 11258f0484fSRodney W. GrimesEach successive 11358f0484fSRodney W. Grimes.Em pointer 11458f0484fSRodney W. Grimesargument must correspond properly with 11558f0484fSRodney W. Grimeseach successive conversion specifier 11638261ac8SDima Dorfman(but see the 11738261ac8SDima Dorfman.Cm * 11838261ac8SDima Dorfmanconversion below). 11958f0484fSRodney W. GrimesAll conversions are introduced by the 12058f0484fSRodney W. Grimes.Cm % 12158f0484fSRodney W. Grimes(percent sign) character. 12258f0484fSRodney W. GrimesThe 12358f0484fSRodney W. Grimes.Fa format 12458f0484fSRodney W. Grimesstring 12558f0484fSRodney W. Grimesmay also contain other characters. 12658f0484fSRodney W. GrimesWhite space (such as blanks, tabs, or newlines) in the 12758f0484fSRodney W. Grimes.Fa format 12858f0484fSRodney W. Grimesstring match any amount of white space, including none, in the input. 12958f0484fSRodney W. GrimesEverything else 13058f0484fSRodney W. Grimesmatches only itself. 13158f0484fSRodney W. GrimesScanning stops 13258f0484fSRodney W. Grimeswhen an input character does not match such a format character. 13358f0484fSRodney W. GrimesScanning also stops 13458f0484fSRodney W. Grimeswhen an input conversion cannot be made (see below). 13558f0484fSRodney W. Grimes.Sh CONVERSIONS 13658f0484fSRodney W. GrimesFollowing the 13758f0484fSRodney W. Grimes.Cm % 13858f0484fSRodney W. Grimescharacter introducing a conversion 13958f0484fSRodney W. Grimesthere may be a number of 14058f0484fSRodney W. Grimes.Em flag 14158f0484fSRodney W. Grimescharacters, as follows: 142946b2d00SBill Fenner.Bl -tag -width ".Cm l No (ell)" 14358f0484fSRodney W. Grimes.It Cm * 14458f0484fSRodney W. GrimesSuppresses assignment. 14558f0484fSRodney W. GrimesThe conversion that follows occurs as usual, but no pointer is used; 14658f0484fSRodney W. Grimesthe result of the conversion is simply discarded. 147946b2d00SBill Fenner.It Cm hh 148946b2d00SBill FennerIndicates that the conversion will be one of 149946b2d00SBill Fenner.Cm dioux 150946b2d00SBill Fenneror 151946b2d00SBill Fenner.Cm n 152946b2d00SBill Fennerand the next pointer is a pointer to a 153432e57ebSRuslan Ermilov.Vt char 154946b2d00SBill Fenner(rather than 155432e57ebSRuslan Ermilov.Vt int ) . 15658f0484fSRodney W. Grimes.It Cm h 15758f0484fSRodney W. GrimesIndicates that the conversion will be one of 15858f0484fSRodney W. Grimes.Cm dioux 15958f0484fSRodney W. Grimesor 16058f0484fSRodney W. Grimes.Cm n 16158f0484fSRodney W. Grimesand the next pointer is a pointer to a 162432e57ebSRuslan Ermilov.Vt "short int" 16358f0484fSRodney W. Grimes(rather than 164432e57ebSRuslan Ermilov.Vt int ) . 165946b2d00SBill Fenner.It Cm l No (ell) 166946b2d00SBill FennerIndicates that the conversion will be one of 16758f0484fSRodney W. Grimes.Cm dioux 16858f0484fSRodney W. Grimesor 16958f0484fSRodney W. Grimes.Cm n 17058f0484fSRodney W. Grimesand the next pointer is a pointer to a 171432e57ebSRuslan Ermilov.Vt "long int" 17258f0484fSRodney W. Grimes(rather than 173432e57ebSRuslan Ermilov.Vt int ) , 174946b2d00SBill Fennerthat the conversion will be one of 175946b2d00SBill Fenner.Cm aefg 17658f0484fSRodney W. Grimesand the next pointer is a pointer to 177432e57ebSRuslan Ermilov.Vt double 17858f0484fSRodney W. Grimes(rather than 179432e57ebSRuslan Ermilov.Vt float ) , 180946b2d00SBill Fenneror that the conversion will be one of 1814712aa3bSTim J. Robbins.Cm c , 182946b2d00SBill Fenner.Cm s 1834712aa3bSTim J. Robbinsor 1844712aa3bSTim J. Robbins.Cm \&[ 185946b2d00SBill Fennerand the next pointer is a pointer to an array of 186432e57ebSRuslan Ermilov.Vt wchar_t 187946b2d00SBill Fenner(rather than 188432e57ebSRuslan Ermilov.Vt char ) . 189946b2d00SBill Fenner.It Cm ll No (ell ell) 190946b2d00SBill FennerIndicates that the conversion will be one of 1915e17038fSJordan K. Hubbard.Cm dioux 1925e17038fSJordan K. Hubbardor 1935e17038fSJordan K. Hubbard.Cm n 1945e17038fSJordan K. Hubbardand the next pointer is a pointer to a 195432e57ebSRuslan Ermilov.Vt "long long int" 1965e17038fSJordan K. Hubbard(rather than 197432e57ebSRuslan Ermilov.Vt int ) . 198946b2d00SBill Fenner.It Cm L 199946b2d00SBill FennerIndicates that the conversion will be one of 200946b2d00SBill Fenner.Cm aef 201946b2d00SBill Fenneror 202946b2d00SBill Fenner.Cm g 203946b2d00SBill Fennerand the next pointer is a pointer to 204432e57ebSRuslan Ermilov.Vt "long double" . 205946b2d00SBill Fenner(This type is not implemented; although the argument is 206946b2d00SBill Fennerrequired to be a pointer to 207432e57ebSRuslan Ermilov.Vt "long double" , 208946b2d00SBill Fennerno additional precision is used in the conversion.) 209946b2d00SBill Fenner.It Cm j 210946b2d00SBill FennerIndicates that the conversion will be one of 211946b2d00SBill Fenner.Cm dioux 212946b2d00SBill Fenneror 213946b2d00SBill Fenner.Cm n 214946b2d00SBill Fennerand the next pointer is a pointer to a 215432e57ebSRuslan Ermilov.Vt intmax_t 216946b2d00SBill Fenner(rather than 217432e57ebSRuslan Ermilov.Vt int ) . 218946b2d00SBill Fenner.It Cm t 219946b2d00SBill FennerIndicates that the conversion will be one of 220946b2d00SBill Fenner.Cm dioux 221946b2d00SBill Fenneror 222946b2d00SBill Fenner.Cm n 223946b2d00SBill Fennerand the next pointer is a pointer to a 224432e57ebSRuslan Ermilov.Vt ptrdiff_t 225946b2d00SBill Fenner(rather than 226432e57ebSRuslan Ermilov.Vt int ) . 227946b2d00SBill Fenner.It Cm z 228946b2d00SBill FennerIndicates that the conversion will be one of 229946b2d00SBill Fenner.Cm dioux 230946b2d00SBill Fenneror 231946b2d00SBill Fenner.Cm n 232946b2d00SBill Fennerand the next pointer is a pointer to a 233432e57ebSRuslan Ermilov.Vt size_t 234946b2d00SBill Fenner(rather than 235432e57ebSRuslan Ermilov.Vt int ) . 236946b2d00SBill Fenner.It Cm q 237946b2d00SBill Fenner(deprecated.) 238946b2d00SBill FennerIndicates that the conversion will be one of 239946b2d00SBill Fenner.Cm dioux 240946b2d00SBill Fenneror 241946b2d00SBill Fenner.Cm n 242946b2d00SBill Fennerand the next pointer is a pointer to a 243432e57ebSRuslan Ermilov.Vt "long long int" 244946b2d00SBill Fenner(rather than 245432e57ebSRuslan Ermilov.Vt int ) . 24658f0484fSRodney W. Grimes.El 24758f0484fSRodney W. Grimes.Pp 24858f0484fSRodney W. GrimesIn addition to these flags, 24958f0484fSRodney W. Grimesthere may be an optional maximum field width, 25058f0484fSRodney W. Grimesexpressed as a decimal integer, 25158f0484fSRodney W. Grimesbetween the 25258f0484fSRodney W. Grimes.Cm % 25358f0484fSRodney W. Grimesand the conversion. 25458f0484fSRodney W. GrimesIf no width is given, 255432e57ebSRuslan Ermilova default of 256432e57ebSRuslan Ermilov.Dq infinity 257432e57ebSRuslan Ermilovis used (with one exception, below); 2584712aa3bSTim J. Robbinsotherwise at most this many bytes are scanned 25958f0484fSRodney W. Grimesin processing the conversion. 2604712aa3bSTim J. RobbinsIn the case of the 2614712aa3bSTim J. Robbins.Cm lc , 2624712aa3bSTim J. Robbins.Cm ls 2634712aa3bSTim J. Robbinsand 2644712aa3bSTim J. Robbins.Cm l[ 2654712aa3bSTim J. Robbinsconversions, the field width specifies the maximum number 2664712aa3bSTim J. Robbinsof multibyte characters that will be scanned. 26758f0484fSRodney W. GrimesBefore conversion begins, 26858f0484fSRodney W. Grimesmost conversions skip white space; 26958f0484fSRodney W. Grimesthis white space is not counted against the field width. 27058f0484fSRodney W. Grimes.Pp 27158f0484fSRodney W. GrimesThe following conversions are available: 27258f0484fSRodney W. Grimes.Bl -tag -width XXXX 27358f0484fSRodney W. Grimes.It Cm % 274432e57ebSRuslan ErmilovMatches a literal 275432e57ebSRuslan Ermilov.Ql % . 276432e57ebSRuslan ErmilovThat is, 277432e57ebSRuslan Ermilov.Dq Li %% 278432e57ebSRuslan Ermilovin the format string 279432e57ebSRuslan Ermilovmatches a single input 280432e57ebSRuslan Ermilov.Ql % 281432e57ebSRuslan Ermilovcharacter. 28258f0484fSRodney W. GrimesNo conversion is done, and assignment does not occur. 28358f0484fSRodney W. Grimes.It Cm d 28458f0484fSRodney W. GrimesMatches an optionally signed decimal integer; 28558f0484fSRodney W. Grimesthe next pointer must be a pointer to 286432e57ebSRuslan Ermilov.Vt int . 28758f0484fSRodney W. Grimes.It Cm i 28858f0484fSRodney W. GrimesMatches an optionally signed integer; 28958f0484fSRodney W. Grimesthe next pointer must be a pointer to 290432e57ebSRuslan Ermilov.Vt int . 29158f0484fSRodney W. GrimesThe integer is read in base 16 if it begins 29258f0484fSRodney W. Grimeswith 29358f0484fSRodney W. Grimes.Ql 0x 29458f0484fSRodney W. Grimesor 29558f0484fSRodney W. Grimes.Ql 0X , 29658f0484fSRodney W. Grimesin base 8 if it begins with 29758f0484fSRodney W. Grimes.Ql 0 , 29858f0484fSRodney W. Grimesand in base 10 otherwise. 29958f0484fSRodney W. GrimesOnly characters that correspond to the base are used. 30058f0484fSRodney W. Grimes.It Cm o 30158f0484fSRodney W. GrimesMatches an octal integer; 30258f0484fSRodney W. Grimesthe next pointer must be a pointer to 303432e57ebSRuslan Ermilov.Vt "unsigned int" . 30458f0484fSRodney W. Grimes.It Cm u 30558f0484fSRodney W. GrimesMatches an optionally signed decimal integer; 30658f0484fSRodney W. Grimesthe next pointer must be a pointer to 307432e57ebSRuslan Ermilov.Vt "unsigned int" . 308946b2d00SBill Fenner.It Cm x , X 30958f0484fSRodney W. GrimesMatches an optionally signed hexadecimal integer; 31058f0484fSRodney W. Grimesthe next pointer must be a pointer to 311432e57ebSRuslan Ermilov.Vt "unsigned int" . 312946b2d00SBill Fenner.It Cm e , E , f , F , g , G 31358f0484fSRodney W. GrimesMatches an optionally signed floating-point number; 31458f0484fSRodney W. Grimesthe next pointer must be a pointer to 315432e57ebSRuslan Ermilov.Vt float . 316946b2d00SBill Fenner.It Cm a , A 317946b2d00SBill FennerMatches a hexadecimal number represented in the style 318946b2d00SBill Fenner.Sm off 319946b2d00SBill Fenner.Oo \- Oc Li 0x Ar h Li \&. Ar hhh Cm p Oo \\*[Pm] Oc Ar d . 320946b2d00SBill Fenner.Sm on 321946b2d00SBill FennerThis is an exact conversion of the sign, exponent, mantissa internal 322946b2d00SBill Fennerfloating point representation; the 323946b2d00SBill Fenner.Sm off 324946b2d00SBill Fenner.Oo \- Oc Li 0x Ar h Li \&. Ar hhh 325946b2d00SBill Fenner.Sm on 326946b2d00SBill Fennerportion represents exactly the mantissa; only denormalized 327946b2d00SBill Fennermantissas have a zero value to the left of the hexadecimal 328946b2d00SBill Fennerpoint. 329946b2d00SBill FennerThe 330946b2d00SBill Fenner.Cm p 331946b2d00SBill Fenneris a literal character 332946b2d00SBill Fenner.Ql p ; 333946b2d00SBill Fennerthe exponent is preceded by a positive or negative sign 334946b2d00SBill Fennerand is represented in decimal. 33558f0484fSRodney W. Grimes.It Cm s 33658f0484fSRodney W. GrimesMatches a sequence of non-white-space characters; 33758f0484fSRodney W. Grimesthe next pointer must be a pointer to 338432e57ebSRuslan Ermilov.Vt char , 33958f0484fSRodney W. Grimesand the array must be large enough to accept all the sequence and the 34058f0484fSRodney W. Grimesterminating 34158f0484fSRodney W. Grimes.Dv NUL 34258f0484fSRodney W. Grimescharacter. 34358f0484fSRodney W. GrimesThe input string stops at white space 34458f0484fSRodney W. Grimesor at the maximum field width, whichever occurs first. 3454712aa3bSTim J. Robbins.Pp 3464712aa3bSTim J. RobbinsIf an 3474712aa3bSTim J. Robbins.Cm l 3484712aa3bSTim J. Robbinsqualifier is present, the next pointer must be a pointer to 3494712aa3bSTim J. Robbins.Vt wchar_t , 3504712aa3bSTim J. Robbinsinto which the input will be placed after conversion by 3514712aa3bSTim J. Robbins.Xr mbrtowc 3 . 352946b2d00SBill Fenner.It Cm S 353946b2d00SBill FennerThe same as 354946b2d00SBill Fenner.Cm ls . 35558f0484fSRodney W. Grimes.It Cm c 35658f0484fSRodney W. GrimesMatches a sequence of 35758f0484fSRodney W. Grimes.Em width 35858f0484fSRodney W. Grimescount 35958f0484fSRodney W. Grimescharacters (default 1); 36058f0484fSRodney W. Grimesthe next pointer must be a pointer to 361432e57ebSRuslan Ermilov.Vt char , 36258f0484fSRodney W. Grimesand there must be enough room for all the characters 36358f0484fSRodney W. Grimes(no terminating 36458f0484fSRodney W. Grimes.Dv NUL 36558f0484fSRodney W. Grimesis added). 36658f0484fSRodney W. GrimesThe usual skip of leading white space is suppressed. 36758f0484fSRodney W. GrimesTo skip white space first, use an explicit space in the format. 3684712aa3bSTim J. Robbins.Pp 3694712aa3bSTim J. RobbinsIf an 3704712aa3bSTim J. Robbins.Cm l 3714712aa3bSTim J. Robbinsqualifier is present, the next pointer must be a pointer to 3724712aa3bSTim J. Robbins.Vt wchar_t , 3734712aa3bSTim J. Robbinsinto which the input will be placed after conversion by 3744712aa3bSTim J. Robbins.Xr mbrtowc 3 . 375946b2d00SBill Fenner.It Cm C 376946b2d00SBill FennerThe same as 377946b2d00SBill Fenner.Cm lc . 37858f0484fSRodney W. Grimes.It Cm \&[ 37958f0484fSRodney W. GrimesMatches a nonempty sequence of characters from the specified set 38058f0484fSRodney W. Grimesof accepted characters; 38158f0484fSRodney W. Grimesthe next pointer must be a pointer to 382432e57ebSRuslan Ermilov.Vt char , 38358f0484fSRodney W. Grimesand there must be enough room for all the characters in the string, 38458f0484fSRodney W. Grimesplus a terminating 38558f0484fSRodney W. Grimes.Dv NUL 38658f0484fSRodney W. Grimescharacter. 38758f0484fSRodney W. GrimesThe usual skip of leading white space is suppressed. 38858f0484fSRodney W. GrimesThe string is to be made up of characters in 38958f0484fSRodney W. Grimes(or not in) 39058f0484fSRodney W. Grimesa particular set; 39158f0484fSRodney W. Grimesthe set is defined by the characters between the open bracket 39258f0484fSRodney W. Grimes.Cm [ 39358f0484fSRodney W. Grimescharacter 39458f0484fSRodney W. Grimesand a close bracket 39558f0484fSRodney W. Grimes.Cm ] 39658f0484fSRodney W. Grimescharacter. 39758f0484fSRodney W. GrimesThe set 39858f0484fSRodney W. Grimes.Em excludes 39958f0484fSRodney W. Grimesthose characters 40058f0484fSRodney W. Grimesif the first character after the open bracket is a circumflex 40158f0484fSRodney W. Grimes.Cm ^ . 40258f0484fSRodney W. GrimesTo include a close bracket in the set, 40358f0484fSRodney W. Grimesmake it the first character after the open bracket 40458f0484fSRodney W. Grimesor the circumflex; 40558f0484fSRodney W. Grimesany other position will end the set. 40658f0484fSRodney W. GrimesThe hyphen character 40758f0484fSRodney W. Grimes.Cm - 40858f0484fSRodney W. Grimesis also special; 40958f0484fSRodney W. Grimeswhen placed between two other characters, 41058f0484fSRodney W. Grimesit adds all intervening characters to the set. 41158f0484fSRodney W. GrimesTo include a hyphen, 41258f0484fSRodney W. Grimesmake it the last character before the final close bracket. 41358f0484fSRodney W. GrimesFor instance, 41458f0484fSRodney W. Grimes.Ql [^]0-9-] 415432e57ebSRuslan Ermilovmeans the set 416432e57ebSRuslan Ermilov.Dq "everything except close bracket, zero through nine, and hyphen" . 41758f0484fSRodney W. GrimesThe string ends with the appearance of a character not in the 41858f0484fSRodney W. Grimes(or, with a circumflex, in) set 41958f0484fSRodney W. Grimesor when the field width runs out. 4204712aa3bSTim J. Robbins.Pp 4214712aa3bSTim J. RobbinsIf an 4224712aa3bSTim J. Robbins.Cm l 4234712aa3bSTim J. Robbinsqualifier is present, the next pointer must be a pointer to 4244712aa3bSTim J. Robbins.Vt wchar_t , 4254712aa3bSTim J. Robbinsinto which the input will be placed after conversion by 4264712aa3bSTim J. Robbins.Xr mbrtowc 3 . 42758f0484fSRodney W. Grimes.It Cm p 42858f0484fSRodney W. GrimesMatches a pointer value (as printed by 42958f0484fSRodney W. Grimes.Ql %p 43058f0484fSRodney W. Grimesin 43158f0484fSRodney W. Grimes.Xr printf 3 ) ; 43258f0484fSRodney W. Grimesthe next pointer must be a pointer to 433432e57ebSRuslan Ermilov.Vt void . 43458f0484fSRodney W. Grimes.It Cm n 43558f0484fSRodney W. GrimesNothing is expected; 43658f0484fSRodney W. Grimesinstead, the number of characters consumed thus far from the input 43758f0484fSRodney W. Grimesis stored through the next pointer, 43858f0484fSRodney W. Grimeswhich must be a pointer to 439432e57ebSRuslan Ermilov.Vt int . 44058f0484fSRodney W. GrimesThis is 44158f0484fSRodney W. Grimes.Em not 44258f0484fSRodney W. Grimesa conversion, although it can be suppressed with the 44358f0484fSRodney W. Grimes.Cm * 44458f0484fSRodney W. Grimesflag. 44558f0484fSRodney W. Grimes.El 44658f0484fSRodney W. Grimes.Pp 44736db5680SAndrey A. ChernovThe decimal point 448429d919cSRuslan Ermilovcharacter is defined in the program's locale (category 449429d919cSRuslan Ermilov.Dv LC_NUMERIC ) . 45036db5680SAndrey A. Chernov.Pp 451432e57ebSRuslan ErmilovFor backwards compatibility, a 452432e57ebSRuslan Ermilov.Dq conversion 453432e57ebSRuslan Ermilovof 45458f0484fSRodney W. Grimes.Ql %\e0 45558f0484fSRodney W. Grimescauses an immediate return of 45658f0484fSRodney W. Grimes.Dv EOF . 45758f0484fSRodney W. Grimes.Sh RETURN VALUES 45858f0484fSRodney W. GrimesThese 45958f0484fSRodney W. Grimesfunctions 46058f0484fSRodney W. Grimesreturn 46158f0484fSRodney W. Grimesthe number of input items assigned, which can be fewer than provided 46258f0484fSRodney W. Grimesfor, or even zero, in the event of a matching failure. 46358f0484fSRodney W. GrimesZero 46458f0484fSRodney W. Grimesindicates that, while there was input available, 46558f0484fSRodney W. Grimesno conversions were assigned; 46658f0484fSRodney W. Grimestypically this is due to an invalid input character, 46758f0484fSRodney W. Grimessuch as an alphabetic character for a 46858f0484fSRodney W. Grimes.Ql %d 46958f0484fSRodney W. Grimesconversion. 47058f0484fSRodney W. GrimesThe value 47158f0484fSRodney W. Grimes.Dv EOF 47258f0484fSRodney W. Grimesis returned if an input failure occurs before any conversion such as an 473c6ff3a1bSSheldon Hearnend-of-file occurs. 474c6ff3a1bSSheldon HearnIf an error or end-of-file occurs after conversion 47558f0484fSRodney W. Grimeshas begun, 47658f0484fSRodney W. Grimesthe number of conversions which were successfully completed is returned. 47758f0484fSRodney W. Grimes.Sh SEE ALSO 47858f0484fSRodney W. Grimes.Xr getc 3 , 47938b5abadSTim J. Robbins.Xr mbrtowc 3 , 48075141cc9SWolfram Schneider.Xr printf 3 , 48175141cc9SWolfram Schneider.Xr strtod 3 , 48275141cc9SWolfram Schneider.Xr strtol 3 , 48338b5abadSTim J. Robbins.Xr strtoul 3 , 48438b5abadSTim J. Robbins.Xr wscanf 3 48558f0484fSRodney W. Grimes.Sh STANDARDS 48658f0484fSRodney W. GrimesThe functions 48758f0484fSRodney W. Grimes.Fn fscanf , 48858f0484fSRodney W. Grimes.Fn scanf , 4895a7405beSTim J. Robbins.Fn sscanf , 4905a7405beSTim J. Robbins.Fn vfscanf , 4915a7405beSTim J. Robbins.Fn vscanf 49258f0484fSRodney W. Grimesand 4935a7405beSTim J. Robbins.Fn vsscanf 49458f0484fSRodney W. Grimesconform to 495946b2d00SBill Fenner.St -isoC-99 . 49658f0484fSRodney W. Grimes.Sh BUGS 497946b2d00SBill FennerEarlier implementations of 498946b2d00SBill Fenner.Nm 499946b2d00SBill Fennertreated 500946b2d00SBill Fenner.Cm \&%D , \&%E , \&%F , \&%O 50158f0484fSRodney W. Grimesand 502946b2d00SBill Fenner.Cm \&%X 503946b2d00SBill Fenneras their lowercase equivalents with an 504946b2d00SBill Fenner.Cm l 505432e57ebSRuslan Ermilovmodifier. 506432e57ebSRuslan ErmilovIn addition, 507946b2d00SBill Fenner.Nm 508946b2d00SBill Fennertreated an unknown conversion character as 509946b2d00SBill Fenner.Cm \&%d 510946b2d00SBill Fenneror 511946b2d00SBill Fenner.Cm \&%D , 512432e57ebSRuslan Ermilovdepending on its case. 513432e57ebSRuslan ErmilovThis functionality has been removed. 51458f0484fSRodney W. Grimes.Pp 51558f0484fSRodney W. GrimesNumerical strings are truncated to 512 characters; for example, 51658f0484fSRodney W. Grimes.Cm %f 51758f0484fSRodney W. Grimesand 51858f0484fSRodney W. Grimes.Cm %d 51958f0484fSRodney W. Grimesare implicitly 52058f0484fSRodney W. Grimes.Cm %512f 52158f0484fSRodney W. Grimesand 52258f0484fSRodney W. Grimes.Cm %512d . 523946b2d00SBill Fenner.Pp 524946b2d00SBill FennerThe 525946b2d00SBill Fenner.Cm %n$ 526946b2d00SBill Fennermodifiers for positional arguments are not implemented. 527946b2d00SBill Fenner.Pp 528946b2d00SBill FennerThe 529946b2d00SBill Fenner.Cm \&%a 530946b2d00SBill Fennerand 531946b2d00SBill Fenner.Cm \&%A 532946b2d00SBill Fennerfloating-point formats are not implemented. 533e2b090f3STim J. Robbins.Pp 534e2b090f3STim J. RobbinsThe 535e2b090f3STim J. Robbins.Nm 536e2b090f3STim J. Robbinsfamily of functions do not correctly handle multibyte characters in the 537e2b090f3STim J. Robbins.Fa format 538e2b090f3STim J. Robbinsargument. 539