Reads a line of wide characters from a specified file.
#include <wchar.h>
wchar_t *fgetws (wchar_t *wstr, int maxchar, FILE
*file_ptr);
Function Variants
This function also has variants named _fgetws32 and _fgetws64 for
use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using
pointer-size-specific functions.
| x | Pointer to wstr. |
| NULL | Indicates the end-of-file or an error occurred. The contents of wstr are undefined if a read error occurs. If a read error occurs, the function sets errno. For a list of possible errno values, see fgetwc in this section. |
#include <stdlib.h>
#include <stdio.h>
#include <locale.h>
#include <wchar.h>
main()
{
wchar_t wstr[80], *ret;
FILE *fp;
/* Open a test file containing : "THIS IS A TEST." */
if ((fp = fopen("file.dat", "r")) == (FILE*) NULL) {
perror ("File open error");
exit(EXIT_FAILURE);
}
ret = fgetws(wstr, 80, fp);
if (ret == (wchar_t *) NULL) {
perror ("fgetws failure");
exit(EXIT_FAILURE);
}
fputws(wstr,stdout);
fclose(fp);
}