Fgetws

<code>fgetws</code> is a function in the C programming language. It is wide-character version of the function <code>fgets</code>. The w in <code>fgetws</code> is for wide. A string is read as a multibyte-character or a wide character string by <code>fgetws</code> depending on whether the stream is opened in text/binary mode respectively .The <code>fgetws</code> 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.
Syntax
<source lang="c">
#include <stdio.h>
#include <wchar.h>
wchar_t *fgetws(
wchar_t *string;
int n;
FILE *stream ;
);
</source>
Parameters
fgetws has three parameters:
# <code>string</code> - a string used to provide storage location for data
# <code>n</code> - the maximum number of readable characters
# <code>stream</code> - 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 compulsarily. 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
 
< Prev   Next >