📄 fwscanf.html
字号:
in floating-point format) to support the ANSI/IEEE Std 754:1985 standard, the<i>fwscanf()</i>family of functions will recognise them as input.<dt>s<dd>Matches a sequence of non white-space wide-characters. If nol (ell) qualifier is present, characters from the input field areconverted as if by repeated calls to the<i><a href="wcrtomb.html">wcrtomb()</a></i>function, with the conversion state described by an<b>mbstate_t</b>object initialised to zero before the first wide-character isconverted. The corresponding argument must be a pointer to acharacter arraylarge enough to accept the sequence and the terminating null character, which will be added automatically.Otherwise, the corresponding argument must be a pointer to an arrayof<b>wchar_t</b>large enough to accept the sequence and the terminating null wide-character, which will be added automatically.<dt>[<dd>Matches a non-empty sequence of wide-characters from a set of expectedwide-characters (the<i>scanset</i>).If no l (ell) qualifier is present, wide-characters from the inputfield are converted as if by repeated calls to the<i><a href="wcrtomb.html">wcrtomb()</a></i>function, with the conversion state described by an<b>mbstate_t</b>object initialised to zero before the first wide-character isconverted. The corresponding argument must be a pointer to acharacter arraylarge enough to accept the sequence and the terminating null character, which will be added automatically.If an l (ell) qualifier is present, the corresponding argument must be a pointer to an array of<b>wchar_t</b>large enough to accept the sequence and the terminating null wide-character, which will be added automatically.The conversion specification includes all subsequent widw charactersin the<i>format</i>string up to and including the matching right square bracket (]).The wide-characters between the square brackets (the<i>scanlist</i>)comprise the scanset, unless the wide-character after the left square bracketis a circumflex (^), in which case the scanset contains allwide-characters that do not appear in the scanlist between thecircumflex and the right square bracket.If the conversion specification begins with []or [^], the right square bracket is included in the scanlist and thenext right square bracket is the matching right square bracket that ends theconversion specification; otherwise the first right square bracket is theone that ends the conversion specification.If a - is in the scanlist and is not the first wide-character, nor the secondwhere the first wide-character is a ^, nor the last wide-character,the behaviour is implementation-dependent.<dt>c<dd>Matches a sequence of wide-characters of the number specified by thefield width (1 if no field width is present in the conversion specification).If no l (ell) qualifier is present, wide-characters from the inputfield are converted as if by repeated calls to the<i><a href="wcrtomb.html">wcrtomb()</a></i>function, with the conversion state described by an<b>mbstate_t</b>object initialised to zero before the first wide-character isconverted. The corresponding argument must be a pointer to acharacter array large enough to accept the sequence. No nullcharacter is added.Otherwise, the corresponding argument must be a pointer to an arrayof<b>wchar_t</b>large enough to accept the sequence. No null wide-character is added.<dt>p<dd>Matches an implementation-dependent set of sequences, which mustbe the same as the set of sequences that is produced by the %pconversion of the corresponding<i><a href="fwprintf.html">fwprintf()</a></i>functions.The corresponding argument must be a pointer to a pointer to<b>void</b>.The interpretation of the input item is implementation-dependent.If the input item is a value converted earlier during thesame program execution, the pointer that results will compare equalto that value; otherwise the behaviour of the %p conversion is undefined.<dt>n<dd>No input is consumed.The corresponding argument must be a pointer tothe integer into which is to be written the number ofwide-characters read from the input so far by this call to the<i>fwscanf()</i>functions.Execution of a %nconversion specificationdoes not increment the assignment count returned at thecompletion of execution of the function.<dt>C<dd>Same as <b>lc</b>.<dt>S<dd>Same as <b>ls</b>.<dt>%<dd>Matches a single %;no conversion or assignment occurs.The complete conversion specification must be %%.</dl><p>If a conversion specification is invalid, the behaviour isundefined.<p>The conversion characters E, G and Xare also valid and behave the same as, respectively, e, g and x.<p>If end-of-file is encountered during input, conversion is terminated.If end-of-file occurs before any wide-characters matching the currentconversion specification (except for%n) have been read(other than leading white-space, wherepermitted), execution of the current conversion specificationterminates with aninput failure. Otherwise, unless execution of the currentconversion specification is terminated with a matching failure,execution of the following conversion specification (if any)is terminated with an input failure.<p>Reaching the end of the string in<i><a href="swscanf.html">swscanf()</a></i>is equivalent to encountering end-of-file for<i>fwscanf()</i>.<p>If conversion terminates on a conflicting input, theoffending input is left unread in the input.Any trailing white space (including newline) is leftunread unless matched by a conversion specification.The success of literal matches and suppressed assignments is onlydirectly determinable via the %n conversion specification.<p>The<i>fwscanf()</i>and<i><a href="wscanf.html">wscanf()</a></i>functions may mark the<i>st_atime</i>field of the file associated with<i>stream</i>for update.The<i>st_atime</i>field will be marked for update by the first successful execution of<i><a href="fgetc.html">fgetc()</a></i>,<i><a href="fgetwc.html">fgetwc()</a></i>,<i><a href="fgets.html">fgets()</a></i>,<i><a href="fgetws.html">fgetws()</a></i>,<i><a href="fread.html">fread()</a></i>,<i><a href="getc.html">getc()</a></i>,<i><a href="getwc.html">getwc()</a></i>,<i><a href="getchar.html">getchar()</a></i>,<i><a href="getwchar.html">getwchar()</a></i>,<i><a href="gets.html">gets()</a></i>,<i><a href="fscanf.html">fscanf()</a></i>or<i>fwscanf()</i>using<i>stream</i>that returns data not supplied by a prior call to<i><a href="ungetc.html">ungetc()</a></i>.</blockquote><h4><a name = "tag_000_005_425"> </a>RETURN VALUE</h4><blockquote>Upon successful completion, these functions return the number of successfullymatched and assigned input items; this number can be 0 in the event of anearly matching failure. If the input ends before the first matching failureor conversion, EOF is returned. If a read error occurs the error indicatorfor the stream is set, EOF is returned, and<i>errno</i>is set to indicate the error.</blockquote><h4><a name = "tag_000_005_426"> </a>ERRORS</h4><blockquote>For the conditions under which the<i>fwscanf()</i>functions will fail and may fail, refer to<i><a href="fgetwc.html">fgetwc()</a></i>.<p>In addition,<i>fwscanf()</i>may fail if:<dl compact><dt>[EILSEQ]<dd>Input byte sequence does not form a valid character.<dt>[EINVAL]<dd>There are insufficient arguments.</dl></blockquote><h4><a name = "tag_000_005_427"> </a>EXAMPLES</h4><blockquote>The call:<pre><code>int i, n; float x; char name[50];n = wscanf(L"%d%f%s", &i, &x, name);</code></pre>with the input line:<pre><code>25 54.32E-1 Hamster</code></pre>will assign to<i>n</i>the value 3, to<i>i</i>the value 25, to<i>x</i>the value 5.432, and<i>name</i>will contain the string Hamster.<p>The call:<pre><code>int i; float x; char name[50];(void) wscanf(L"%2d%f%*d %[0123456789]", &i, &x, name);</code></pre>with input:<pre><code>56789 0123 56a72</code></pre><p>will assign 56 to<i>i</i>,789.0 to<i>x</i>,skip 0123, and place the string 56\0 in<i>name</i>.The next call to<i><a href="getchar.html">getchar()</a></i>will return the character a.</blockquote><h4><a name = "tag_000_005_428"> </a>APPLICATION USAGE</h4><blockquote>In format strings containing the % form of conversion specifications,each argument in the argument list is used exactly once.</blockquote><h4><a name = "tag_000_005_429"> </a>FUTURE DIRECTIONS</h4><blockquote>None.</blockquote><h4><a name = "tag_000_005_430"> </a>SEE ALSO</h4><blockquote><i><a href="getwc.html">getwc()</a></i>,<i><a href="fwprintf.html">fwprintf()</a></i>,<i><a href="setlocale.html">setlocale()</a></i>,<i><a href="wcstod.html">wcstod()</a></i>,<i><a href="wcstol.html">wcstol()</a></i>,<i><a href="wcstoul.html">wcstoul()</a></i>,<i><a href="wcrtomb.html">wcrtomb()</a></i>,<i><a href="langinfo.h.html"><langinfo.h></a></i>,<i><a href="stdio.h.html"><stdio.h></a></i>,<i><a href="wchar.h.html"><wchar.h></a></i>,the <b>XBD</b> specification, <a href="../xbd/locale.html"><b>Locale</b> </a>.</blockquote><h4>DERIVATION</h4><blockquote>Derived from the ISO/IEC 9899:1990/Amendment 1:1995 (E).</blockquote><hr size=2 noshade><center><font size=2>UNIX ® is a registered Trademark of The Open Group.<br>Copyright © 1997 The Open Group<br> [ <a href="../index.html">Main Index</a> | <a href="../xshix.html">XSH</a> | <a href="../xcuix.html">XCU</a> | <a href="../xbdix.html">XBD</a> | <a href="../cursesix.html">XCURSES</a> | <a href="../xnsix.html">XNS</a> ]</font></center><hr size=2 noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -