vfwscanf - C wchar.h

C examples for wchar.h:vfwscanf

Type

function

From


<cwchar>
<wchar.h>

Description

Read formatted data from stream into variable argument list

Prototype

int vfwscanf (FILE* stream, const wchar_t* format, va_list arg);

Parameters

Parameter Description
stream Pointer to a FILE object
format a scanf format string
arg variable arguments list

Return Value

On success, the function returns the number of items of the argument list filled.

On error, EOF is returned.

Demo Code


#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;
}

Related Tutorials