C examples for wchar.h:vfwscanf
function
<cwchar> <wchar.h>
Read formatted data from stream into variable argument list
int vfwscanf (FILE* stream, const wchar_t* format, va_list arg);
Parameter | Description |
---|---|
stream | Pointer to a FILE object |
format | a scanf format string |
arg | variable arguments list |
On success, the function returns the number of items of the argument list filled.
On error, EOF is returned.
#include <stdio.h> #include <stdarg.h> #include <wchar.h> void ReadWideStuff (FILE * stream, const wchar_t * format, ...) { va_list args;//ww w.ja v a 2 s . c o m va_start (args, format); vfwscanf (stream, format, args); va_end (args); } int main () { FILE * pFile; int val; wchar_t str[100]; pFile = fopen ("main.cpp","r"); if (pFile!=NULL) { ReadWideStuff ( pFile, L" %ls %d ", str, &val ); wprintf (L"I have read %ls and %d", str, val); fclose (pFile); } return 0; }