swprintf - C wchar.h

C examples for wchar.h:swprintf

Type

function

from

<cwchar>

Description

Write formatted data to wide string

Prototype

int swprintf (wchar_t* ws, size_t len, const wchar_t* format, ...);

Parameters

Parameter Description
ws a buffer to store the resulting C wide string
len Maximum number of wide characters to fill
format a printf format string

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 <wchar.h>

int main ()//from  www. j  a  va2  s.  co  m
{
  wchar_t buffer [100];
  int cx;

  cx = swprintf ( buffer, 100, L"this is a test %d and %d %f", 80, 1000 ,123.123);

  swprintf ( buffer+cx, 100-cx-1, L", and the half of that is %d.", 80/2/2 );

  fputws ( buffer, stdout );

  return 0;
}

Related Tutorials