fwprintf - C wchar.h

C examples for wchar.h:fwprintf

Type

function

From


<cwchar>
<wchar.h>

Description

Write formatted data to stream

Prototype

int fwprintf (FILE* stream, const wchar_t* format, ...);

Parameters

Parameter Description
stream Pointer to a FILE object
format C wide format string that follow the same specifications as format in printf

Return Value

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

On error, the error indicator (ferror) is set and a negative number is returned.

If a multibyte character encoding error occurs while writing wide characters, errno is set to EILSEQ and a negative number is returned.

Demo Code


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

int main ()// www  .j  a  va 2 s . c o m
{
   FILE * pFile;

   wchar_t name [100];

   pFile = fopen ("main.cpp","w");

   for (int n=0 ; n<3 ; n++)
   {
     fwprintf (stdout, L"please, enter a name: ");
     fgetws (name, 100, stdin);
     fwprintf (pFile, L"Name %d: %s",n,name);
   }
   fclose (pFile);

   return 0;
}

Related Tutorials