C examples for wchar.h:fgetws
function
<cwchar> <wchar.h>
Get wide string from stream
wchar_t* fgetws (wchar_t* ws, int num, FILE* stream);
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. |
On success, the function returns str.
If the end-of-file is encountered, the eof indicator is set (feof).
#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; }