C Programming/wchar.h/fgetws

  is a function in the C programming language. It is wide-character version of the function. The w in  is for wide. A string is read as a multibyte-character or a wide character string  by   depending on whether the stream is opened in text/binary mode respectively. The  subroutine reads characters from the input stream, converts them to the corresponding wide character codes, and places them in the array pointed to by the string parameter.

The subroutine continues until either:
 * The number of characters specified by the number parameter '-1' are read
 * The subroutine encounters a newline or EOF character.

The fgetws subroutine terminates the wide character string with a NULL wide character.

Parameters
fgetws has three parameters:
 * 1)   - a string used to provide storage location for data
 * 2)   - the maximum number of readable characters
 * 3)   - a FILE pointer

Requirements
Although fgetws is wider relative to fgets, it can be compiled by an additional optional header along with stdio.h called wchar.h. However, fgets requires stdio.h compulsorily. Hence, fgetws provides option.

Return value
Just as fgets function, fgetws function also returns the same value string i.e. a ws is returned on success. The error condition is taken care-of by this function using a NULL pointer. A Null pointer is returned to the function-called for error or even at EOF(end of file). One can use also use the feof or ferror for error determination.

Compatibility
ubuntu, fedora, ANSI, Win 98, Win Me, Win NT, Win 2000, Win XP