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

📄 fwscanf.html

📁 unix 下的C开发手册,还用详细的例程。
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><!-- Copyright 1997 The Open Group, All Rights Reserved --><title>fwscanf</title></head><body bgcolor=white><center><font size=2>The Single UNIX &reg; Specification, Version 2<br>Copyright &copy; 1997 The Open Group</font></center><hr size=2 noshade><h4><a name = "tag_000_005_422">&nbsp;</a>NAME</h4><blockquote>fwscanf, wscanf, swscanf  - convert formatted wide-character input</blockquote><h4><a name = "tag_000_005_423">&nbsp;</a>SYNOPSIS</h4><blockquote><pre><code>#include &lt;<a href="stdio.h.html">stdio.h</a>&gt;#include &lt;<a href="wchar.h.html">wchar.h</a>&gt;int fwscanf(FILE *<i>stream</i>, const wchar_t *<i>format</i>, ... );int wscanf(const wchar_t *<i>format</i>, ... );int swscanf(const wchar_t *<i>s</i>, const wchar_t *<i>format</i>, ... );</code></pre></blockquote><h4><a name = "tag_000_005_424">&nbsp;</a>DESCRIPTION</h4><blockquote>The<i>fwscanf()</i>function reads from the named input<i>stream</i>.The<i><a href="wscanf.html">wscanf()</a></i>function reads from the standard input stream<i>stdin</i>.The<i><a href="swscanf.html">swscanf()</a></i>function reads from the wide-character string<i>s</i>.Each function reads wide-characters, interpretsthem according to a format, and stores the results in its arguments.Each expects, as arguments, a control wide-character string<i>format</i>described below, and a set of<i>pointer</i>argumentsindicating where the converted input should be stored.The result is undefined if there are insufficient arguments forthe format.If the format is exhausted while arguments remain, the excess argumentsare evaluated but are otherwise ignored.<p>Conversions can be applied to the<i>nth</i>argument after the<i>format</i>in the argument list, rather than to the next unused argument.In this case, the conversion wide-character % (see below) is replacedby the sequence %<i>n</i>$, where <i>n</i> is a decimal integerin the range [1,&nbsp;{NL_ARGMAX}].This feature provides for the definition of format wide-characterstrings thatselect arguments in an order appropriate to specific languages.In format wide-character stringscontaining the %<i>n</i>$ form of conversion specifications,it is unspecified whether numberedarguments in the argument list can be referenced from the format wide-character string more than once.<p>The<i>format</i>can contain either form of a conversion specification, that is, %or %<i>n</i>$, but the two forms cannot normally be mixed within a single<i>format</i>wide-character string.The only exception to this is that %% or %* can be mixed with the%<i>n</i>$ form.<p>The<i>fwscanf()</i>function in all its forms allows for detection of a language-dependent radixcharacter in the input string, encoded as a wide-character value.  The radix character is definedin the program's locale (category LC_NUMERIC).In the POSIX locale, or in a locale wherethe radix character is not defined,the radix character defaults to a period (.).<p>The format is a wide-character stringcomposed of zero or more directives.Each directive is composed of one of the following:one or more white-space wide-characters (space, tab, newline, vertical-tab or form-feed characters); an ordinary wide-character(neither % nor a white-space character);or a conversion specification.Each conversion specification is introduced by a %or the sequence<i>%n$</i>after which the following appear in sequence:<ul><p><li>An optional assignment-suppressing character *.<p><li>An optional non-zero decimal integer that specifies the maximum fieldwidth.<p><li>An optional size modifier h, l (ell) or Lindicating the size of the receiving object.The conversion wide-characters c, s and [ must be precede by l(ell) if the corresponding argument is a pointer to<b>wchar_t</b>rather than a pointer to a character type.The conversion wide-characters d, i and n must be preceded by hif the corresponding argument is a pointer to<b>short int</b>rather than a pointer to<b>int</b>,or by l (ell) if it is a pointer to<b>long int</b>.Similarly, the conversion wide-characters o, u and x must be preceded by hif the corresponding argument is a pointer to<b>unsigned short int</b>rather than a pointer to<b>unsigned int</b>or by l (ell) if it is a pointer to<b>unsigned long int</b>.The conversion wide-characters e, f and g must be preceded by l (ell)if the corresponding argument is a pointer to<b>double</b>rather than a pointer to<b>float</b>,or by L if it is a pointer to<b>long double</b>.If an h, l (ell) or Lappears with any other conversion wide-character, the behaviour is undefined.<p><li>A conversion wide-characterthat specifies the type of conversion to be applied.The valid conversion wide-characters are described below.<p></ul><p>The<i>fwscanf()</i>functions execute each directive of the format in turn.  If a directive fails,as detailed below, the function returns.  Failures are described as inputfailures (due to the unavailability of input bytes) or matching failures (dueto inappropriate input).<p>A directive composed of one or more white-space wide-characters isexecuted by reading input until no more valid input can be read, orup to the first wide-character which is not a white-space wide-character, which remains unread.<p>A directive that is an ordinary wide-character is executed asfollows.The next wide-character is read from the input and compared with thewide-character that comprises the directive;if the comparison shows that they are not equivalent,the directive fails, and the differing and subsequentwide-characters remain unread.<p>A directive that is a conversion specification defines a set ofmatching input sequences, as described below for each conversion wide-character.A conversion specification is executed in the following steps:<p>Input white-space wide-characters (as specified by<i><a href="iswspace.html">iswspace()</a></i>)are skipped, unless the conversion specification includes a[, c or n conversion character.<p>An item is read from the input, unless the conversion specificationincludes an n conversion wide-character.An input item is defined as the longest sequence of input wide-characters, not exceeding any specified field width,which is aninitial subsequence of a matching sequence.The first wide-character, if any, after the input item remains unread.If the length of the input item is 0, the execution of theconversion specification fails;this condition is a matching failure, unless end-of-file, an encodingerror, or a read error preventedinput from the stream, in which case it is an input failure.<p>Except in the case of a % conversion wide-character, the input item (or, in the case of a<i>%n</i>conversion specification, the count of input wide-characters)is converted to a type appropriate to the conversion wide-character.If the input item is not a matching sequence, the execution ofthe conversion specification fails; this condition is a matching failure.Unless assignment suppression was indicated by a *,the result of the conversion is placed in the object pointed toby the first argument following the<i>format</i>argument that has not already received a conversion resultif the conversion specification is introduced by %,&nbsp;or in the<i>n</i>thargument if introduced by the wide-character sequence<i>%n$</i>.&nbsp;If this object does not have an appropriate type, or if theresult of the conversion cannot be represented in the spaceprovided, the behaviour is undefined.<p>The following conversion wide-characters are valid:<dl compact><dt>d<dd>Matches an optionally signed decimal integer, whose format is thesame as expected for the subject sequence of<i><a href="wcstol.html">wcstol()</a></i>with the value 10 for the<i>base</i>argument.In the absence of a size modifier, the corresponding argumentmust be a pointer to<b>int</b>.<dt>i<dd>Matches an optionally signed integer, whose format is the same asexpected for the subject sequence of<i><a href="wcstol.html">wcstol()</a></i>with 0 for the<i>base</i>argument.In the absence of a size modifier, the corresponding argumentmust be a pointer to<b>int</b>.<dt>o<dd>Matches an optionally signed octal integer, whose format is the same asexpected for the subject sequence of<i><a href="wcstoul.html">wcstoul()</a></i>with the value 8 for the<i>base</i>argument.In the absence of a size modifier, the corresponding argumentmust be a pointer to<b>unsigned int</b>.<dt>u<dd>Matches an optionally signed decimal integer, whose format is thesame as expected for the subject sequence of<i><a href="wcstoul.html">wcstoul()</a></i>with the value 10 for the<i>base</i>argument.In the absence of a size modifier, the corresponding argumentmust be a pointer to<b>unsigned int</b>.<dt>x<dd>Matches an optionally signed hexadecimal integer, whose format isthe same as expected for the subject sequence of<i><a href="wcstoul.html">wcstoul()</a></i>with the value 16 for the<i>base</i>argument.In the absence of a size modifier, the corresponding argumentmust be a pointer to<b>unsigned int</b>.<dt>e,&nbsp;f,&nbsp;g<dd>Matches an optionally signed floating-point number, whose format isthe same as expected for the subject sequence of<i><a href="wcstod.html">wcstod()</a></i>.In the absence of a size modifier, the corresponding argumentmust be a pointer to<b>float</b>.If the<i><a href="fwprintf.html">fwprintf()</a></i>family of functions generates character stringrepresentations for infinity and NaN (a 7858 symbolic entity encoded

⌨️ 快捷键说明

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