fgetws - C wchar.h

C examples for wchar.h:fgetws

Type

function

From


<cwchar>
<wchar.h>

Description

Get wide string from stream

Prototype

wchar_t* fgetws (wchar_t* ws, int num, FILE* stream);

Parameters

Parameter Description
ws an array of wchar_t where the wide string read is copied.
num Maximum number of characters to be copied into str.
stream Pointer to a FILE object.

Return Value

On success, the function returns str.

If the end-of-file is encountered, the eof indicator is set (feof).

Demo Code


#include <stdio.h>

int main()//from   w ww .ja v  a  2s.co  m
{
   FILE * pFile;
   wchar_t mystring [100];

   pFile = fopen ("main.cpp" , "r");

   if (pFile == NULL){
      perror("cannot open file");
      return -1;
   }

   if ( fgetws (mystring , 100 , pFile) != NULL )
       fputws ( mystring, stdout );
   fclose (pFile);

   return 0;
}

Related Tutorials