Стандарт языка Си С99 TC (1113411), страница 67
Текст из файла (страница 67)
The corresponding argument shall be a pointer tosigned integer.iMatches an optionally signed integer, whose format is the same as expectedfor the subject sequence of the wcstol function with the value 0 for thebase argument. The corresponding argument shall be a pointer to signed358Library§7.24.2.2WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3integer.oMatches an optionally signed octal integer, whose format is the same asexpected for the subject sequence of the wcstoul function with the value 8for the base argument. The corresponding argument shall be a pointer tounsigned integer.uMatches an optionally signed decimal integer, whose format is the same asexpected for the subject sequence of the wcstoul function with the value 10for the base argument. The corresponding argument shall be a pointer tounsigned integer.xMatches an optionally signed hexadecimal integer, whose format is the sameas expected for the subject sequence of the wcstoul function with the value16 for the base argument.
The corresponding argument shall be a pointer tounsigned integer.a,e,f,g Matches an optionally signed floating-point number, infinity, or NaN, whoseformat is the same as expected for the subject sequence of the wcstodfunction. The corresponding argument shall be a pointer to floating.cMatches a sequence of wide characters of exactly the number specified by thefield width (1 if no field width is present in the directive).If no l length modifier is present, characters from the input field areconverted as if by repeated calls to the wcrtomb function, with theconversion state described by an mbstate_t object initialized to zerobefore the first wide character is converted.
The corresponding argumentshall be a pointer to the initial element of a character array large enough toaccept the sequence. No null character is added.If an l length modifier is present, the corresponding argument shall be apointer to the initial element of an array of wchar_t large enough to acceptthe sequence. No null wide character is added.sMatches a sequence of non-white-space wide characters.If no l length modifier is present, characters from the input field areconverted as if by repeated calls to the wcrtomb function, with theconversion state described by an mbstate_t object initialized to zerobefore the first wide character is converted.
The corresponding argumentshall be a pointer to the initial element of a character array large enough toaccept the sequence and a terminating null character, which will be addedautomatically.If an l length modifier is present, the corresponding argument shall be apointer to the initial element of an array of wchar_t large enough to accept§7.24.2.2Library359ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256the sequence and the terminating null wide character, which will be addedautomatically.[Matches a nonempty sequence of wide characters from a set of expectedcharacters (the scanset).If no l length modifier is present, characters from the input field areconverted as if by repeated calls to the wcrtomb function, with theconversion state described by an mbstate_t object initialized to zerobefore the first wide character is converted.
The corresponding argumentshall be a pointer to the initial element of a character array large enough toaccept the sequence and a terminating null character, which will be addedautomatically.If an l length modifier is present, the corresponding argument shall be apointer to the initial element of an array of wchar_t large enough to acceptthe sequence and the terminating null wide character, which will be addedautomatically.The conversion specifier includes all subsequent wide characters in theformat string, up to and including the matching right bracket (]). The widecharacters between the brackets (the scanlist) compose the scanset, unless thewide character after the left bracket is a circumflex (^), in which case thescanset contains all wide characters that do not appear in the scanlist betweenthe circumflex and the right bracket. If the conversion specifier begins with[] or [^], the right bracket wide character is in the scanlist and the nextfollowing right bracket wide character is the matching right bracket that endsthe specification; otherwise the first following right bracket wide character isthe one that ends the specification.
If a - wide character is in the scanlist andis not the first, nor the second where the first wide character is a ^, nor thelast character, the behavior is implementation-defined.pMatches an implementation-defined set of sequences, which should be thesame as the set of sequences that may be produced by the %p conversion ofthe fwprintf function. The corresponding argument shall be a pointer to apointer to void. The input item is converted to a pointer value in animplementation-defined manner. If the input item is a value converted earlierduring the same program execution, the pointer that results shall compareequal to that value; otherwise the behavior of the %p conversion is undefined.nNo input is consumed. The corresponding argument shall be a pointer tosigned integer into which is to be written the number of wide characters readfrom the input stream so far by this call to the fwscanf function.
Executionof a %n directive does not increment the assignment count returned at thecompletion of execution of the fwscanf function. No argument is360Library§7.24.2.2WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3converted, but one is consumed. If the conversion specification includes anassignment-suppressing wide character or a field width, the behavior isundefined.Matches a single % wide character; no conversion or assignment occurs. Thecomplete conversion specification shall be %%.%13If a conversion specification is invalid, the behavior is undefined.290)14The conversion specifiers A, E, F, G, and X are also valid and behave the same as,respectively, a, e, f, g, and x.15Trailing white space (including new-line wide characters) is left unread unless matchedby a directive.
The success of literal matches and suppressed assignments is not directlydeterminable other than via the %n directive.Returns16The fwscanf function returns the value of the macro EOF if an input failure occursbefore any conversion. Otherwise, the function returns the number of input itemsassigned, which can be fewer than provided for, or even zero, in the event of an earlymatching failure.17EXAMPLE 1The call:#include <stdio.h>#include <wchar.h>/* ... */int n, i; float x; wchar_t name[50];n = fwscanf(stdin, L"%d%f%ls", &i, &x, name);with the input line:25 54.32E-1 thompsonwill assign to n the value 3, to i the value 25, to x the value 5.432, and to name the sequencethompson\0.18EXAMPLE 2The call:#include <stdio.h>#include <wchar.h>/* ...
*/int i; float x; double y;fwscanf(stdin, L"%2d%f%*d %lf", &i, &x, &y);with input:56789 0123 56a72will assign to i the value 56 and to x the value 789.0, will skip past 0123, and will assign to y the value56.0. The next wide character read from the input stream will be a.290) See ‘‘future library directions’’ (7.26.12).§7.24.2.2Library361ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256Forward references: the wcstod, wcstof, and wcstold functions (7.24.4.1.1), thewcstol, wcstoll, wcstoul, and wcstoull functions (7.24.4.1.2), the wcrtombfunction (7.24.6.3.3).7.24.2.3 The swprintf functionSynopsis1#include <wchar.h>int swprintf(wchar_t * restrict s,size_t n,const wchar_t * restrict format, ...);Description2The swprintf function is equivalent to fwprintf, except that the argument sspecifies an array of wide characters into which the generated output is to be written,rather than written to a stream.
No more than n wide characters are written, including aterminating null wide character, which is always added (unless n is zero).Returns3The swprintf function returns the number of wide characters written in the array, notcounting the terminating null wide character, or a negative value if an encoding erroroccurred or if n or more wide characters were requested to be written.7.24.2.4 The swscanf functionSynopsis1#include <wchar.h>int swscanf(const wchar_t * restrict s,const wchar_t * restrict format, ...);Description2The swscanf function is equivalent to fwscanf, except that the argument s specifies awide string from which the input is to be obtained, rather than from a stream.