vswprintf - C wchar.h

C examples for wchar.h:vswprintf

Type

function

From


<cwchar>
<wchar.h>

Description

Write formatted data from variable argument list to sized buffer

Prototype

int vswprintf (wchar_t * ws, size_t len, const wchar_t * format, va_list arg );

Parameters

Parameter Description
ws Pointer to a buffer
len Maximum number of wide characters to be written to the buffer.
format a printf format string
arg a variable arguments list

Return Value

On success, the total number of characters written is returned.

A negative number is returned on failure.

Demo Code


#include <stdio.h>
#include <stdarg.h>
#include <wchar.h>

void PrintWide ( const wchar_t * format, ... )
{
  wchar_t buffer[256];/*from  ww w  . j av a  2 s . co  m*/
  va_list args;
  va_start ( args, format );
  vswprintf ( buffer, 256, format, args );
  fputws ( buffer, stdout );
  va_end ( args );
}

int main ()
{
   wchar_t str[] = L"test string has %d wide characters.\n";

   PrintWide ( str, wcslen(str) );

   return 0;
}

Related Tutorials