C examples for wchar.h:vswprintf
function
<cwchar> <wchar.h>
Write formatted data from variable argument list to sized buffer
int vswprintf (wchar_t * ws, size_t len, const wchar_t * format, va_list arg );
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 |
On success, the total number of characters written is returned.
A negative number is returned on failure.
#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; }