Previous Page
Next Page


Writes formatted output in a wide-character string to a file

#include <stdio.h>
#include <wchar.h>
int fwprintf ( FILE * restrict fp , const wchar_t * restrict format , ... );

The fwprintf( ) function is similar to fprintf( ), except that its format string argument and its output are strings of wide characters.


wchar_t name_local[ ]   = L"Ka\u0142u\u017Cny";
char    name_portable[ ]= "Kaluzny";
char    locale[ ]       = "pl_PL.UTF-8";
char *  newlocale;

newlocale = setlocale( LC_ALL, locale );
if ( newlocale == NULL )
  fprintf( stderr, "Sorry, couldn't change the locale to %s.\n"
           "The current locale is %s.\n",
           locale, setlocale( LC_ALL, NULL ));

fwprintf( stdout,
          L"Customer's name: %ls (Single-byte transliteration: %s)\n",
          name_local, name_portable );

If the specified Polish locale is available, this example produces the output:

Customer's name: Kauny (Single-byte transliteration: Kaluzny)

See Also

The byte-character output function fprintf( ); the wide-character input functions fgetwc, fgetws, getwc, getwchar, fwscanf, wscanf, vfwscanf, and vwscanf; the wide-character output functions fputwc, fputws, putwc, putwchar, wprintf, vfwprintf, and vwprintf.

Previous Page
Next Page