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

📄 wscanf.html

📁 posix标准英文,html格式
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2004 IEEE and The Open Group, All Rights Reserved --><title>fwscanf</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="fwscanf"></a> <a name="tag_03_206"></a><!-- fwscanf --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2004 Edition<br>Copyright &copy; 2001-2004 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_03_206_01"></a>NAME</h4><blockquote>fwscanf, swscanf, wscanf - convert formatted wide-character input</blockquote><h4><a name="tag_03_206_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><p><code><tt>#include &lt;<a href="../basedefs/stdio.h.html">stdio.h</a>&gt;<br> #include &lt;<a href="../basedefs/wchar.h.html">wchar.h</a>&gt;<br><br> int fwscanf(FILE *restrict</tt> <i>stream</i><tt>, const wchar_t *restrict</tt> <i>format</i><tt>, ... );<br> int swscanf(const wchar_t *restrict</tt> <i>ws</i><tt>,<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; const wchar_t *restrict</tt> <i>format</i><tt>, ... );<br> int wscanf(const wchar_t *restrict</tt> <i>format</i><tt>, ... );<br></tt></code></p></blockquote><h4><a name="tag_03_206_03"></a>DESCRIPTION</h4><blockquote><div class="box"><sup>[<a href="javascript:open_code('CX')">CX</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]"border="0"> The functionality described on this reference page is aligned with the ISO&nbsp;C standard. Any conflict between therequirements described here and the ISO&nbsp;C standard is unintentional. This volume of IEEE&nbsp;Std&nbsp;1003.1-2001 defers tothe ISO&nbsp;C standard. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></div><p>The <i>fwscanf</i>() function shall read from the named input <i>stream</i>. The <i>wscanf</i>() function shall read from thestandard input stream <i>stdin</i>. The <i>swscanf</i>() function shall read from the wide-character string <i>ws</i>. Eachfunction reads wide characters, interprets them according to a format, and stores the results in its arguments. Each expects, asarguments, a control wide-character string <i>format</i> described below, and a set of <i>pointer</i> arguments indicating wherethe converted input should be stored. The result is undefined if there are insufficient arguments for the format. If the<i>format</i> is exhausted while arguments remain, the excess arguments are evaluated but are otherwise ignored.</p><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Conversions can be applied to the <i>n</i>th argument after the <i>format</i> in the argument list, rather than to the next unusedargument. In this case, the conversion specifier wide character <tt>%</tt> (see below) is replaced by the sequence <tt>"%n$"</tt>,where <i>n</i> is a decimal integer in the range [1,{NL_ARGMAX}]. This feature provides for the definition of <i>format</i>wide-character strings that select arguments in an order appropriate to specific languages. In <i>format</i> wide-character stringscontaining the <tt>"%</tt><i>n</i><tt>$"</tt> form of conversion specifications, it is unspecified whether numbered arguments inthe argument list can be referenced from the <i>format</i> wide-character string more than once.</p><p>The <i>format</i> can contain either form of a conversion specification-that is, <tt>%</tt> or <tt>"%</tt><i>n</i><tt>$"</tt>-but the two forms cannot normally be mixed within a single <i>format</i> wide-character string. The only exception to this is that<tt>%%</tt> or <tt>%*</tt> can be mixed with the <tt>"%</tt><i>n</i><tt>$"</tt> form. When numbered argument specifications areused, specifying the <i>N</i>th argument requires that all the leading arguments, from the first to the ( <i>N</i>-1)th, arepointers. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></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>() function in all its forms allows for detection of a language-dependent radix character in the input string,encoded as a wide-character value. The radix character is defined in the program's locale (category <i>LC_NUMERIC ).</i> In thePOSIX locale, or in a locale where the radix character is not defined, the radix character shall default to a period ( <tt>'.'</tt>). <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p><p>The <i>format</i> is a wide-character string composed of zero or more directives. Each directive is composed of one of thefollowing: one or more white-space wide characters ( &lt;space&gt;s, &lt;tab&gt;s, &lt;newline&gt;s, &lt;vertical-tab&gt;s, or&lt;form-feed&gt;s); an ordinary wide character (neither <tt>'%'</tt> nor a white-space character); or a conversion specification.Each conversion specification is introduced by a <tt>'%'</tt> <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;or the sequence <tt>"%</tt><i>n</i><tt>$"</tt> <img src="../images/opt-end.gif" alt="[Option End]" border="0"> after which the following appear in sequence:</p><ul><li><p>An optional assignment-suppressing character <tt>'*'</tt>.</p></li><li><p>An optional non-zero decimal integer that specifies the maximum field width.</p></li><li><p>An optional length modifier that specifies the size of the receiving object.</p></li><li><p>A conversion specifier wide character that specifies the type of conversion to be applied. The valid conversion specifiers aredescribed below.</p></li></ul><p>The <i>fwscanf</i>() functions shall execute each directive of the format in turn. If a directive fails, as detailed below, thefunction shall return. Failures are described as input failures (due to the unavailability of input bytes) or matching failures(due to inappropriate input).</p><p>A directive composed of one or more white-space wide characters is executed by reading input until no more valid input can beread, or up to the first wide character which is not a white-space wide character, which remains unread.</p><p>A directive that is an ordinary wide character shall be executed as follows. The next wide character is read from the input andcompared with the wide character that comprises the directive; if the comparison shows that they are not equivalent, the directiveshall fail, and the differing and subsequent wide characters remain unread. Similarly, if end-of-file, an encoding error, or a readerror prevents a wide character from being read, the directive shall fail.</p><p>A directive that is a conversion specification defines a set of matching input sequences, as described below for each conversionwide character. A conversion specification is executed in the following steps.</p><p>Input white-space wide characters (as specified by <a href="iswspace.html"><i>iswspace</i>()</a>) shall be skipped, unless theconversion specification includes a <tt>[</tt>, <tt>c</tt>, or <tt>n</tt> conversion specifier.</p><p>An item shall be read from the input, unless the conversion specification includes an <tt>n</tt> conversion specifier widecharacter. An input item is defined as the longest sequence of input wide characters, not exceeding any specified field width,which is an initial subsequence of a matching sequence. The first wide character, if any, after the input item shall remain unread.If the length of the input item is zero, the execution of the conversion specification shall fail; this condition is a matchingfailure, unless end-of-file, an encoding error, or a read error prevented input from the stream, in which case it is an inputfailure.</p><p>Except in the case of a <tt>%</tt> conversion specifier, the input item (or, in the case of a <tt>%n</tt> conversionspecification, the count of input wide characters) shall be converted to a type appropriate to the conversion wide character. Ifthe input item is not a matching sequence, the execution of the conversion specification shall fail; this condition is a matchingfailure. Unless assignment suppression was indicated by a <tt>'*'</tt>, the result of the conversion shall be placed in the objectpointed to by the first argument following the <i>format</i> argument that has not already received a conversion result if theconversion specification is introduced by <tt>%</tt>, <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> &nbsp;or in the <i>n</i>th argument if introduced by the wide-charactersequence <tt>"%</tt><i>n</i><tt>$"</tt>. <img src="../images/opt-end.gif" alt="[Option End]" border="0"> If this object does nothave an appropriate type, or if the result of the conversion cannot be represented in the space provided, the behavior isundefined.</p><p>The length modifiers and their meanings are:</p><dl compact><dt><tt>hh</tt></dt><dd>Specifies that a following <tt>d</tt>, <tt>i</tt>, <tt>o</tt>, <tt>u</tt>, <tt>x</tt>, <tt>X</tt>, or <tt>n</tt>conversion specifier applies to an argument with type pointer to <b>signed char</b> or <b>unsigned char</b>.</dd><dt><tt>h</tt></dt><dd>Specifies that a following <tt>d</tt>, <tt>i</tt>, <tt>o</tt>, <tt>u</tt>, <tt>x</tt>, <tt>X</tt>, or <tt>n</tt>conversion specifier applies to an argument with type pointer to <b>short</b> or <b>unsigned short</b>.</dd><dt><tt>l</tt>&nbsp;(ell)</dt><dd>Specifies that a following <tt>d</tt>, <tt>i</tt>, <tt>o</tt>, <tt>u</tt>, <tt>x</tt>, <tt>X</tt>, or <tt>n</tt>conversion specifier applies to an argument with type pointer to <b>long</b> or <b>unsigned long</b>; that a following <tt>a</tt>,<tt>A</tt>, <tt>e</tt>, <tt>E</tt>, <tt>f</tt>, <tt>F</tt>, <tt>g</tt>, or <tt>G</tt> conversion specifier applies to anargument with type pointer to <b>double</b>; or that a following <tt>c</tt>, <tt>s</tt>, or <tt>[</tt> conversion specifierapplies to an argument with type pointer to <b>wchar_t</b>.</dd><dt><tt>ll</tt>&nbsp;(ell-ell)</dt><dd>Specifies that a following <tt>d</tt>, <tt>i</tt>, <tt>o</tt>, <tt>u</tt>, <tt>x</tt>, <tt>X</tt>, or <tt>n</tt> conversionspecifier applies to an argument with type pointer to <b>long long</b> or <b>unsigned long long</b>.</dd><dt><tt>j</tt></dt><dd>Specifies that a following <tt>d</tt>, <tt>i</tt>, <tt>o</tt>, <tt>u</tt>, <tt>x</tt>, <tt>X</tt>, or <tt>n</tt>conversion specifier applies to an argument with type pointer to <b>intmax_t</b> or <b>uintmax_t</b>.</dd><dt><tt>z</tt></dt><dd>Specifies that a following <tt>d</tt>, <tt>i</tt>, <tt>o</tt>, <tt>u</tt>, <tt>x</tt>, <tt>X</tt>, or <tt>n</tt>conversion specifier applies to an argument with type pointer to <b>size_t</b> or the corresponding signed integer type.</dd><dt><tt>t</tt></dt><dd>Specifies that a following <tt>d</tt>, <tt>i</tt>, <tt>o</tt>, <tt>u</tt>, <tt>x</tt>, <tt>X</tt>, or <tt>n</tt>conversion specifier applies to an argument with type pointer to <b>ptrdiff_t</b> or the corresponding <b>unsigned</b> type.</dd><dt><tt>L</tt></dt><dd>Specifies that a following <tt>a</tt>, <tt>A</tt>, <tt>e</tt>, <tt>E</tt>, <tt>f</tt>, <tt>F</tt>, <tt>g</tt>, or<tt>G</tt> conversion specifier applies to an argument with type pointer to <b>long double</b>.</dd></dl><p>If a length modifier appears with any conversion specifier other than as specified above, the behavior is undefined.</p><p>The following conversion specifier wide characters are valid:</p><dl compact><dt><tt>d</tt></dt><dd>Matches an optionally signed decimal integer, whose format is the same as expected for the subject sequence of <a href="../functions/wcstol.html"><i>wcstol</i>()</a> with the value 10 for the <i>base</i> argument. In the absence of a size modifier,the application shall ensure that the corresponding argument is a pointer to <b>int</b>.</dd><dt><tt>i</tt></dt><dd>Matches an optionally signed integer, whose format is the same as expected for the subject sequence of <a href="../functions/wcstol.html"><i>wcstol</i>()</a> with 0 for the <i>base</i> argument. In the absence of a size modifier, theapplication shall ensure that the corresponding argument is a pointer to <b>int</b>.</dd><dt><tt>o</tt></dt><dd>Matches an optionally signed octal integer, whose format is the same as expected for the subject sequence of <a href="../functions/wcstoul.html"><i>wcstoul</i>()</a> with the value 8 for the <i>base</i> argument. In the absence of a size modifier,the application shall ensure that the corresponding argument is a pointer to <b>unsigned</b>.</dd><dt><tt>u</tt></dt><dd>Matches an optionally signed decimal integer, whose format is the same as expected for the subject sequence of <a href="../functions/wcstoul.html"><i>wcstoul</i>()</a> with the value 10 for the <i>base</i> argument. In the absence of a size modifier,the application shall ensure that the corresponding argument is a pointer to <b>unsigned</b>.</dd><dt><tt>x</tt></dt><dd>Matches an optionally signed hexadecimal integer, whose format is the same as expected for the subject sequence of <a href="../functions/wcstoul.html"><i>wcstoul</i>()</a> with the value 16 for the <i>base</i> argument. In the absence of a size modifier,the application shall ensure that the corresponding argument is a pointer to <b>unsigned</b>.</dd><dt><tt>a</tt>,&nbsp;<tt>e</tt>,&nbsp;<tt>f</tt>,&nbsp;<tt>g</tt></dt><dd>Matches an optionally signed floating-point number, infinity, or NaN whose format is the same as expected for the subject sequenceof <a href="../functions/wcstod.html"><i>wcstod</i>()</a>. In the absence of a size modifier, the application shall ensure that thecorresponding argument is a pointer to <b>float</b>. <p>If the <a href="../functions/fwprintf.html"><i>fwprintf</i>()</a> family of functions generates character string representationsfor infinity and NaN (a symbolic entity encoded in floating-point format) to support IEEE&nbsp;Std&nbsp;754-1985, the<i>fwscanf</i>() family of functions shall recognize them as input.</p></dd><dt><tt>s</tt></dt><dd>Matches a sequence of non white-space wide characters. If no <tt>l</tt> (ell) qualifier is present, characters from the inputfield shall be converted as if by repeated calls to the <a href="../functions/wcrtomb.html"><i>wcrtomb</i>()</a> function, with theconversion state described by an <b>mbstate_t</b> object initialized to zero before the first wide character is converted. Theapplication shall ensure that the corresponding argument is a pointer to a character array large enough to accept the sequence andthe terminating null character, which shall be added automatically. <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 and the terminating null wide character, which shall be added automatically.</p></dd><dt><tt>[</tt></dt><dd>Matches a non-empty sequence of wide characters from a set of expected wide characters (the <i>scanset</i>). If no <tt>l</tt>(ell) qualifier is present, wide characters from the input field shall be converted as if by repeated calls to the <a href="../functions/wcrtomb.html"><i>wcrtomb</i>()</a> function, with the conversion state described by an <b>mbstate_t</b> objectinitialized to zero before the first wide character is converted. The application shall ensure that the corresponding argument is apointer to a character array large enough to accept the sequence and the terminating null character, which shall be added

⌨️ 快捷键说明

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