⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 wscanf.html

📁 posix标准英文,html格式
💻 HTML
📖 第 1 页 / 共 2 页
字号:
automatically. <p>If an <tt>l</tt> (ell) qualifier is present, the application shall ensure that the corresponding argument is a pointer to anarray of <b>wchar_t</b> large enough to accept the sequence and the terminating null wide character, which shall be addedautomatically.</p><p>The conversion specification includes all subsequent wide characters in the <i>format</i> string up to and including thematching right square bracket ( <tt>']'</tt> ). The wide characters between the square brackets (the <i>scanlist</i>) comprise thescanset, unless the wide character after the left square bracket is a circumflex ( <tt>'^'</tt> ), in which case the scansetcontains all wide characters that do not appear in the scanlist between the circumflex and the right square bracket. If theconversion specification begins with <tt>"[]"</tt> or <tt>"[^]"</tt>, the right square bracket is included in the scanlist and thenext right square bracket is the matching right square bracket that ends the conversion specification; otherwise, the first rightsquare bracket is the one that ends the conversion specification. If a <tt>'-'</tt> is in the scanlist and is not the first widecharacter, nor the second where the first wide character is a <tt>'^'</tt>, nor the last wide character, the behavior isimplementation-defined.</p></dd><dt><tt>c</tt></dt><dd>Matches a sequence of wide characters of exactly the number specified by the field width (1 if no field width is present in theconversion specification). <p>If no <tt>l</tt> (ell) length modifier is present, characters from the input field shall be converted as if by repeated calls tothe <a href="../functions/wcrtomb.html"><i>wcrtomb</i>()</a> function, with the conversion state described by an <b>mbstate_t</b>object initialized to zero before the first wide character is converted. The corresponding argument shall be a pointer to theinitial element of a character array large enough to accept the sequence. No null character is added.</p><p>If an <tt>l</tt> (ell) length modifier is present, the corresponding argument shall be a pointer to the initial element of anarray of <b>wchar_t</b> large enough to accept the sequence. No null wide character is added.</p><p>Otherwise, the application shall ensure that the corresponding argument is a pointer to an array of <b>wchar_t</b> large enoughto accept the sequence. No null wide character is added.</p></dd><dt><tt>p</tt></dt><dd>Matches an implementation-defined set of sequences, which shall be the same as the set of sequences that is produced by the<tt>%p</tt> conversion specification of the corresponding <a href="../functions/fwprintf.html"><i>fwprintf</i>()</a> functions. Theapplication shall ensure that the corresponding argument is a pointer to a pointer to <b>void</b>. The interpretation of the inputitem is implementation-defined. If the input item is a value converted earlier during the same program execution, the pointer thatresults shall compare equal to that value; otherwise, the behavior of the <tt>%p</tt> conversion is undefined.</dd><dt><tt>n</tt></dt><dd>No input is consumed. The application shall ensure that the corresponding argument is a pointer to the integer into which is tobe written the number of wide characters read from the input so far by this call to the <i>fwscanf</i>() functions. Execution of a<tt>%n</tt> conversion specification shall not increment the assignment count returned at the completion of execution of thefunction. No argument shall be converted, but one shall be consumed. If the conversion specification includes anassignment-suppressing wide character or a field width, the behavior is undefined.</dd><dt><tt>C</tt></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Equivalent to <tt>lc</tt>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt><tt>S</tt></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Equivalent to <tt>ls</tt>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt><tt>%</tt></dt><dd>Matches a single <tt>'%'</tt> wide character; no conversion or assignment shall occur. The complete conversion specificationshall be <tt>%%</tt>.</dd></dl><p>If a conversion specification is invalid, the behavior is undefined.</p><p>The conversion specifiers <tt>A</tt>, <tt>E</tt>, <tt>F</tt>, <tt>G</tt>, and <tt>X</tt> are also valid and shall beequivalent to, respectively, <tt>a</tt>, <tt>e</tt>, <tt>f</tt>, <tt>g</tt>, and <tt>x</tt>.</p><p>If end-of-file is encountered during input, conversion is terminated. If end-of-file occurs before any wide characters matchingthe current conversion specification (except for <tt>%n</tt> ) have been read (other than leading white-space, where permitted),execution of the current conversion specification shall terminate with an input failure. Otherwise, unless execution of the currentconversion specification is terminated with a matching failure, execution of the following conversion specification (if any) shallbe terminated with an input failure.</p><p>Reaching the end of the string in <i>swscanf</i>() shall be equivalent to encountering end-of-file for <i>fwscanf</i>().</p><p>If conversion terminates on a conflicting input, the offending input shall be left unread in the input. Any trailing white space(including &lt;newline&gt;) shall be left unread unless matched by a conversion specification. The success of literal matches andsuppressed assignments is only directly determinable via the <tt>%n</tt> conversion specification.</p><p><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> The<i>fwscanf</i>() and <i>wscanf</i>() functions may mark the <i>st_atime</i> field of the file associated with <i>stream</i> forupdate. The <i>st_atime</i> field shall be marked for update by the first successful execution of <a href="../functions/fgetc.html"><i>fgetc</i>()</a>, <a href="../functions/fgetwc.html"><i>fgetwc</i>()</a>, <a href="../functions/fgets.html"><i>fgets</i>()</a>, <a href="../functions/fgetws.html"><i>fgetws</i>()</a>, <a href="../functions/fread.html"><i>fread</i>()</a>, <a href="../functions/getc.html"><i>getc</i>()</a>, <a href="../functions/getwc.html"><i>getwc</i>()</a>, <a href="../functions/getchar.html"><i>getchar</i>()</a>, <a href="../functions/getwchar.html"><i>getwchar</i>()</a>, <a href="../functions/gets.html"><i>gets</i>()</a>, <a href="../functions/fscanf.html"><i>fscanf</i>()</a>, or <i>fwscanf</i>() using <i>stream</i> that returns data not supplied by a priorcall to <a href="../functions/ungetc.html"><i>ungetc</i>()</a>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></blockquote><h4><a name="tag_03_206_04"></a>RETURN VALUE</h4><blockquote><p>Upon successful completion, these functions shall return the number of successfully matched and assigned input items; thisnumber can be zero in the event of an early matching failure. If the input ends before the first matching failure or conversion,EOF shall be returned. If a read error occurs, the error indicator for the stream is set, EOF shall be returned, <sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;and<i>errno</i> shall be set to indicate the error. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></blockquote><h4><a name="tag_03_206_05"></a>ERRORS</h4><blockquote><p>For the conditions under which the <i>fwscanf</i>() functions shall fail and may fail, refer to <a href="fgetwc.html"><i>fgetwc</i>()</a>.</p><p>In addition, <i>fwscanf</i>() may fail if:</p><dl compact><dt>[EILSEQ]</dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Input byte sequence does not form a valid character. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd><dt>[EINVAL]</dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">There are insufficient arguments. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_03_206_06"></a>EXAMPLES</h4><blockquote><p>The call:</p><pre><tt>int i, n; float x; char name[50];n = wscanf(L"%d%f%s", &amp;i, &amp;x, name);</tt></pre><p>with the input line:</p><pre><tt>25 54.32E-1 Hamster</tt></pre><p>assigns 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> contains the string<tt>"Hamster"</tt>.</p><p>The call:</p><pre><tt>int i; float x; char name[50];(void) wscanf(L"%2d%f%*d %[0123456789]", &amp;i, &amp;x, name);</tt></pre><p>with input:</p><pre><tt>56789 0123 56a72</tt></pre><p>assigns 56 to <i>i</i>, 789.0 to <i>x</i>, skips 0123, and places the string <tt>"56\0"</tt> in <i>name</i>. The next call to <ahref="../functions/getchar.html"><i>getchar</i>()</a> shall return the character <tt>'a'</tt>.</p></blockquote><h4><a name="tag_03_206_07"></a>APPLICATION USAGE</h4><blockquote><p>In format strings containing the <tt>'%'</tt> form of conversion specifications, each argument in the argument list is usedexactly once.</p></blockquote><h4><a name="tag_03_206_08"></a>RATIONALE</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_206_09"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_03_206_10"></a>SEE ALSO</h4><blockquote><p><a href="getwc.html"><i>getwc</i>()</a>, <a href="fwprintf.html"><i>fwprintf</i>()</a>, <a href="setlocale.html"><i>setlocale</i>()</a>, <a href="wcstod.html"><i>wcstod</i>()</a>, <a href="wcstol.html"><i>wcstol</i>()</a>,<a href="wcstoul.html"><i>wcstoul</i>()</a>, <a href="wcrtomb.html"><i>wcrtomb</i>()</a>, the Base Definitions volume ofIEEE&nbsp;Std&nbsp;1003.1-2001, <a href="../basedefs/xbd_chap07.html">Chapter 7, Locale</a>, <a href="../basedefs/langinfo.h.html"><i>&lt;langinfo.h&gt;</i></a>, <a href="../basedefs/stdio.h.html"><i>&lt;stdio.h&gt;</i></a>, <ahref="../basedefs/wchar.h.html"><i>&lt;wchar.h&gt;</i></a></p></blockquote><h4><a name="tag_03_206_11"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 5. Included for alignment with ISO/IEC&nbsp;9899:1990/Amendment 1:1995 (E).</p></blockquote><h4><a name="tag_03_206_12"></a>Issue 6</h4><blockquote><p>The DESCRIPTION is updated to avoid use of the term &quot;must&quot; for application requirements.</p><p>The following changes are made for alignment with the ISO/IEC&nbsp;9899:1999 standard:</p><ul><li><p>The prototypes for <i>fwscanf</i>() and <i>swscanf</i>() are updated.</p></li><li><p>The DESCRIPTION is updated.</p></li><li><p>The <tt>hh</tt>, <tt>ll</tt>, <tt>j</tt>, <tt>t</tt>, and <tt>z</tt> length modifiers are added.</p></li><li><p>The <tt>a</tt>, <tt>A</tt>, and <tt>F</tt> conversion characters are added.</p></li></ul><p>The DESCRIPTION is updated to use the terms &quot;conversion specifier&quot; and &quot;conversion specification&quot; consistently.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX &reg; is a registered Trademark of The Open Group.<br>POSIX &reg; is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -