Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C Amendment |
both |
#include <stdarg.h>
#include <wchar.h>
int vfwprintf(FILE * __restrict__ stream,
const wchar_t * __restrict__ format, va_list arg);
int vswprintf(wchar_t * __restrict__ wcs, size_t n,
const wchar_t * __restrict__ format, va_list arg);
int vwprintf(const wchar_t * __restrict__ format, va_list arg);
#define _OPEN_SYS_UNLOCKED_EXT 1
#include <wchar.h>
int vfwprintf_unlocked(FILE * __restrict__ stream,
const wchar_t * __restrict__ format, va_list arg);
int vwprintf_unlocked(const wchar_t * __restrict__ format, va_list arg);
#define _XOPEN_SOURCE
#define _MSE_PROTOS
#include <stdarg.h>
#include <wchar.h>
int vfwprintf(FILE * __restrict__ stream,
const wchar_t * __restrict__ format, va_list arg);
int vswprintf(wchar_t * __restrict__ wcs, size_t n,
const wchar_t * __restrict__ format, va_list arg);
int vwprintf(const wchar_t * __restrict__ format, va_list arg);
#define _OPEN_SYS_UNLOCKED_EXT 1
#include <wchar.h>
int vfwprintf_unlocked(FILE * __restrict__ stream,
const wchar_t * __restrict__ format, va_list arg);
int vwprintf_unlocked(const wchar_t * __restrict__ format, va_list arg);
For vswprintf(), a NULL wide character is written at the end of the wide characters written; the NULL wide character is not counted as part of the returned sum. If copying takes place between objects that overlap, the behavior is undefined.
vfwprintf_unlocked() and vwprintf_unlocked() are functionally equivalent to vfwprintf() and vwprintf() with the exception that they are not thread-safe. These functions may safely be used in a multithreaded application if and only if they are called while the invoking thread owns the (FILE*) object, as is the case after a successful call to either the flockfile() or ftrylockfile() function.
Special behavior for XPG4: If you define any feature test macro specifying XPG4 behavior before the statement in your program source file to include the wchar header, then you must also define the _MSE_PROTOS feature test macro to make the declaration of the vfwprintf(), vswprintf(), or vwprintf() function in the wchar header available when you compile your program. Please see Table 1 for a list of XPG4 and other feature test macros.
If successful, vfwprintf(), vswprintf(), and vwprintf() return the number of wide characters written, not counting the terminating NULL wide character.
If unsuccessful, a negative value is returned.
If n or more wide characters were requested to be written, vswprintf() returns a negative value and sets errno to indicate the error.
⁄* CELEBV06 *⁄
#define _XOPEN_SOURCE
#define _MSE_PROTOS
#include <stdio.h>
#include <stdarg.h>
#include <wchar.h>
void vout(wchar_t *, size_t, wchar_t *, ...);
wchar_t *format3 = L"%S %d %S";
wchar_t *format5 = L"%S %d %S %d %S";
int main(void)
{
wchar_t wcstr[100];
vout(wcstr, 100, format3, L"ONE", 2L, L"THREE");
printf("%S\n",wcstr);
vout(wcstr, 100, format5, L"ONE", 2L, L"THREE", 4L, L"FIVE");
printf("%S\n",wcstr);
}
void vout(wchar_t *wcs, size_t n, wchar_t *fmt, ...)
{
va_list arg_ptr;
va_start(arg_ptr, fmt);
if(vswprintf(wcs, n, fmt, arg_ptr)<0)
perror("vswprintf() error");
va_end(arg_ptr);
}