fwscanf - C wchar.h

C examples for wchar.h:fwscanf

Type

function

From


<cwchar>
<wchar.h>

Description

Read formatted data from stream

Prototype

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

Parameters

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

Return Value

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

Demo Code


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

int main ()/*from www .  j a  va 2 s .  c o  m*/
{
  wchar_t str [80];
  float f;
  FILE * pFile;

  pFile = fopen ("main.cpp","w+");
  
  fwprintf (pFile, L"%f %ls", 3.1416, L"PI");
  
  rewind (pFile);
  
  fwscanf (pFile, L"%f", &f);
  
  fwscanf (pFile, L"%ls", str);
  
  fclose (pFile);
  
  wprintf (L"I have read: %f and %ls \n",f,str);
  
  return 0;
}

Related Tutorials