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 93
vwprintf is equivalent to wprintf, except that the variable argument list is replaced by arg, which the va_start macro (and possibly subsequent va_arg calls) will have initialized. vwprintf does not invoke the va_end macro.

For a complete description, see wprintf -- Format Data as Wide Characters and Print.

Return Value
vwprintf returns the number of wide characters transmitted.

If an output error occurred, vwprintf returns a negative value.

Example
This example prints date and time in the form "Monday, April 14, 17:47" followed by pi to five decimal places. Note that date and time may be formatted according to your locale's representation. The printing is done from the vout function, which takes a variable number of arguments and uses vwprintf to print them to stdout.

#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
#include <time.h>
#include <wchar.h>
#include <locale.h>
void vout(wchar_t *fmt,...);
int main(void)
{
   wchar_t *weekday, *month;
   struct tm *newtime;
   time_t ltime;
   struct dtconv *p;
   weekday = (wchar_t *)malloc(sizeof(wchar_t)*20);
   month = (wchar_t *)malloc(sizeof(wchar_t)*20);
   setlocale(LC_ALL,"");
   time(&ltime);
   newtime = localtime(&ltime);
   p = localdtconv();
   mbstowcs(weekday, p->day_names[newtime->tm_wday], sizeof(wchar_t)*20);
   mbstowcs(month, p->month_names[newtime->tm_mon], sizeof(wchar_t)*20);
   vout(L"%ls, %ls %d, %.2d:%.2d\n",
            weekday, month, newtime->tm_mday,
            newtime->tm_hour, newtime->tm_min);
   vout(L"pi = %.5f\n", 4* atan(1.0));
   return 0;
   /*******************************************************************
      The output should be similar to:
      Monday, April 14, 17:47
      pi = 3.15149
   *******************************************************************/
}
void vout(wchar_t *fmt, ...)
{
   va_list arg_ptr;
   va_start(arg_ptr, fmt);
   vwprintf(fmt, arg_ptr);
   va_end(arg_ptr);
}



printf -- Print Formatted Characters
vfprintf -- Print Argument Data to Stream
vprintf -- Print Argument Data
btowc -- Convert Single Byte to Wide Character
mbrtowc -- Convert Multibyte Character to Wide Character
fwprintf -- Format Data as Wide Characters and Write to a Stream
vswprintf -- Format and Write Wide Characters to Buffer
vfwprintf -- Format Argument Data as Wide Characters and Write to a Stream
wprintf -- Format Data as Wide Characters and Print
<stdarg.h>
<wchar.h>