vwprintf() — Format Argument Data as Wide Characters and Print

Format

#include <stdarg.h>
#include <wchar.h>
int vwprintf(const wchar_t *format, va_list arg);

Language Level

ANSI

Threadsafe

Yes

Locale Sensitive

The behavior of this function might be affected by the LC_CTYPE and LC_NUMERIC categories of the current locale. It might also be affected by the LC_UNI_CTYPE and LC_UNI_NUMERIC categories of the current locale if LOCALETYPE(*LOCALEUCS2) or LOCALETYPE(*LOCALEUTF) is specified on the compilation command. This function is not available when LOCALETYPE(*CLD) is specified on the compilation command. For more information, see Understanding CCSIDs and Locales.

Integrated File System Interface

This function is not available when SYSIFCOPT(*NOIFSIO) is specified on the compilation command.

Wide Character Function

See Wide Characters for more information.

Description

The vwprintf() function is equivalent to the wprintf() function, except that the variable argument list is replaced by arg, which the va_start macro (and possibly subsequent va_arg calls) will have initialized. The vwprintf() function does not invoke the va_end macro.

Return Value

The vwprintf() function returns the number of wide characters transmitted. If an output error occurred, the vwprintf() returns a negative value.

Example

This example prints the wide character a. The printing is done from the vout() function, which takes a variable number of arguments and uses the vwprintf() function to print them to stdout.
#include <wchar.h>
#include <stdarg.h>
#include <locale.h>

void vout (wchar_t *fmt, ...);

int main(void)     {
 FILE *stream;
 wchar_t format[] = L"%lc";
 setlocale(LC_ALL, "POSIX");
 vout (format, L'a');
 return(0);

/* A long a is written to stdout, if stdout is written to the screen
   it may get converted back to a single byte 'a'.  */
}

void vout (wchar_t *fmt, ...) {
 va_list arg_ptr;
 va_start (arg_ptr, fmt);
 vwprintf (fmt, arg_ptr);
 va_end (arg_ptr);
}

Related Information