C examples for wchar.h:fwprintf
function
<cwchar> <wchar.h>
Write formatted data to stream
int fwprintf (FILE* stream, const wchar_t* format, ...);
Parameter | Description |
---|---|
stream | Pointer to a FILE object |
format | C wide format string that follow the same specifications as format in printf |
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.
#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; }