Стандарт языка Си С99 TC (1113411), страница 68
Текст из файла (страница 68)
Reachingthe end of the wide string is equivalent to encountering end-of-file for the fwscanffunction.Returns3The swscanf function returns the value of the macro EOF if an input failure occursbefore any conversion. Otherwise, the swscanf function returns the number of inputitems assigned, which can be fewer than provided for, or even zero, in the event of anearly matching failure.362Library§7.24.2.4WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC37.24.2.5 The vfwprintf functionSynopsis1#include <stdarg.h>#include <stdio.h>#include <wchar.h>int vfwprintf(FILE * restrict stream,const wchar_t * restrict format,va_list arg);Description2The vfwprintf function is equivalent to fwprintf, with the variable argument listreplaced by arg, which shall have been initialized by the va_start macro (andpossibly subsequent va_arg calls).
The vfwprintf function does not invoke theva_end macro.291)Returns3The vfwprintf function returns the number of wide characters transmitted, or anegative value if an output or encoding error occurred.4EXAMPLEroutine.The following shows the use of the vfwprintf function in a general error-reporting#include <stdarg.h>#include <stdio.h>#include <wchar.h>void error(char *function_name, wchar_t *format, ...){va_list args;va_start(args, format);// print out name of function causing errorfwprintf(stderr, L"ERROR in %s: ", function_name);// print out remainder of messagevfwprintf(stderr, format, args);va_end(args);}291) As the functions vfwprintf, vswprintf, vfwscanf, vwprintf, vwscanf, and vswscanfinvoke the va_arg macro, the value of arg after the return is indeterminate.§7.24.2.5Library363ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12567.24.2.6 The vfwscanf functionSynopsis1#include <stdarg.h>#include <stdio.h>#include <wchar.h>int vfwscanf(FILE * restrict stream,const wchar_t * restrict format,va_list arg);Description2The vfwscanf function is equivalent to fwscanf, with the variable argument listreplaced by arg, which shall have been initialized by the va_start macro (andpossibly subsequent va_arg calls).
The vfwscanf function does not invoke theva_end macro.291)Returns3The vfwscanf function returns the value of the macro EOF if an input failure occursbefore any conversion. Otherwise, the vfwscanf function returns the number of inputitems assigned, which can be fewer than provided for, or even zero, in the event of anearly matching failure.7.24.2.7 The vswprintf functionSynopsis1#include <stdarg.h>#include <wchar.h>int vswprintf(wchar_t * restrict s,size_t n,const wchar_t * restrict format,va_list arg);Description2The vswprintf function is equivalent to swprintf, with the variable argument listreplaced by arg, which shall have been initialized by the va_start macro (andpossibly subsequent va_arg calls).
The vswprintf function does not invoke theva_end macro.291)Returns3The vswprintf 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 generated.364Library§7.24.2.7WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC37.24.2.8 The vswscanf functionSynopsis1#include <stdarg.h>#include <wchar.h>int vswscanf(const wchar_t * restrict s,const wchar_t * restrict format,va_list arg);Description2The vswscanf function is equivalent to swscanf, with the variable argument listreplaced by arg, which shall have been initialized by the va_start macro (andpossibly subsequent va_arg calls).
The vswscanf function does not invoke theva_end macro.291)Returns3The vswscanf function returns the value of the macro EOF if an input failure occursbefore any conversion. Otherwise, the vswscanf function returns the number of inputitems assigned, which can be fewer than provided for, or even zero, in the event of anearly matching failure.7.24.2.9 The vwprintf functionSynopsis1#include <stdarg.h>#include <wchar.h>int vwprintf(const wchar_t * restrict format,va_list arg);Description2The vwprintf function is equivalent to wprintf, with the variable argument listreplaced by arg, which shall have been initialized by the va_start macro (andpossibly subsequent va_arg calls).
The vwprintf function does not invoke theva_end macro.291)Returns3The vwprintf function returns the number of wide characters transmitted, or a negativevalue if an output or encoding error occurred.§7.24.2.9Library365ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N12567.24.2.10 The vwscanf functionSynopsis1#include <stdarg.h>#include <wchar.h>int vwscanf(const wchar_t * restrict format,va_list arg);Description2The vwscanf function is equivalent to wscanf, with the variable argument listreplaced by arg, which shall have been initialized by the va_start macro (andpossibly subsequent va_arg calls). The vwscanf function does not invoke theva_end macro.291)Returns3The vwscanf function returns the value of the macro EOF if an input failure occursbefore any conversion. Otherwise, the vwscanf function returns the number of inputitems assigned, which can be fewer than provided for, or even zero, in the event of anearly matching failure.7.24.2.11 The wprintf functionSynopsis1#include <wchar.h>int wprintf(const wchar_t * restrict format, ...);Description2The wprintf function is equivalent to fwprintf with the argument stdoutinterposed before the arguments to wprintf.Returns3The wprintf function returns the number of wide characters transmitted, or a negativevalue if an output or encoding error occurred.7.24.2.12 The wscanf functionSynopsis1#include <wchar.h>int wscanf(const wchar_t * restrict format, ...);Description2The wscanf function is equivalent to fwscanf with the argument stdin interposedbefore the arguments to wscanf.366Library§7.24.2.12WG14/N1256Committee Draft — Septermber 7, 2007ISO/IEC 9899:TC3Returns3The wscanf function returns the value of the macro EOF if an input failure occursbefore any conversion.
Otherwise, the wscanf function returns the number of inputitems assigned, which can be fewer than provided for, or even zero, in the event of anearly matching failure.7.24.3 Wide character input/output functions7.24.3.1 The fgetwc functionSynopsis1#include <stdio.h>#include <wchar.h>wint_t fgetwc(FILE *stream);Description2If the end-of-file indicator for the input stream pointed to by stream is not set and anext wide character is present, the fgetwc function obtains that wide character as awchar_t converted to a wint_t and advances the associated file position indicator forthe stream (if defined).Returns3If the end-of-file indicator for the stream is set, or if the stream is at end-of-file, the endof-file indicator for the stream is set and the fgetwc function returns WEOF.
Otherwise,the fgetwc function returns the next wide character from the input stream pointed to bystream. If a read error occurs, the error indicator for the stream is set and the fgetwcfunction returns WEOF. If an encoding error occurs (including too few bytes), the value ofthe macro EILSEQ is stored in errno and the fgetwc function returns WEOF.292)7.24.3.2 The fgetws functionSynopsis1#include <stdio.h>#include <wchar.h>wchar_t *fgetws(wchar_t * restrict s,int n, FILE * restrict stream);Description2The fgetws function reads at most one less than the number of wide charactersspecified by n from the stream pointed to by stream into the array pointed to by s. No292) An end-of-file and a read error can be distinguished by use of the feof and ferror functions.Also, errno will be set to EILSEQ by input/output functions only if an encoding error occurs.§7.24.3.2Library367ISO/IEC 9899:TC3Committee Draft — Septermber 7, 2007WG14/N1256additional wide characters are read after a new-line wide character (which is retained) orafter end-of-file.
A null wide character is written immediately after the last widecharacter read into the array.Returns3The fgetws function returns s if successful. If end-of-file is encountered and nocharacters have been read into the array, the contents of the array remain unchanged and anull pointer is returned. If a read or encoding error occurs during the operation, the arraycontents are indeterminate and a null pointer is returned.7.24.3.3 The fputwc functionSynopsis1#include <stdio.h>#include <wchar.h>wint_t fputwc(wchar_t c, FILE *stream);Description2The fputwc function writes the wide character specified by c to the output streampointed to by stream, at the position indicated by the associated file position indicatorfor the stream (if defined), and advances the indicator appropriately.