A pointer to a wide-character string, where each element is of type `wchar_t`. Used for representing text in wide-character encoding to support extended character sets.
A pointer to a wide-character string, where each element is of type `wchar_t`. Used for representing text in wide-character encoding to support extended character sets.
1st Parameter
Pointer to the buffer where the wide string will be stored
2nd Parameter Type : int
Integer type (typically 4 bytes, -2,147,483,648 to 2,147,483,647)
2nd Parameter
The maximum number of wide characters to read, including the null terminator
3rd Parameter Type : FILE *
Pointer to FILE structure for file operations
3rd Parameter
Pointer to the file stream from which the wide string is to be read
Read more about parameters of fgetws in parameters section
The fgetwsfunction in C language Reads a line of wide characters from a stream.
The fgetws function reads wide characters from stream and stores them as a wide-character string into ws until (n-1) characters have been read or either a newline or the end-of-file is reached, whichever happens first. A null wide character is automatically appended after the characters read. This function is similar to fgets, but it reads wide characters instead of single-byte characters.
The fgetwsfunction takes 3
parameters:
•
wchar_t * `ws`: Pointer to the buffer where the wide string will be stored
•
int `n`: The maximum number of wide characters to read, including the null terminator
•
FILE * `stream`: Pointer to the file stream from which the wide string is to be read
Reads at most `n-1` wide characters from the specified file stream and stores them in the buffer pointed to by `ws`. The function stops reading on encountering a newline character or the end-of-file. The resulting wide string is null-terminated.
The fgetws function return value :
On success, the function returns ws
If the end-of-file is encountered while attempting to read a character, the eof indicator is set
If this happens before any characters could be read, the function returns NULL
If a read error occurs, the error indicator is set and NULL is returned
Output
This example demonstrates the basic usage of `fgetws`. It reads a file containing wide characters line by line and prints each line to the console.