getwchar Function

Obtains wide character input from the stdin stream.

Attention: This function is implemented only by MPLAB XC32 C compilers.

Include

<wchar.h>

Prototype

wint_t getwchar(void);

Return Value

Returns the next available wide character as a wchar_t converted to a wint_t. The WEOF wide character is returned if the end-of-file indicator for the stream is set, if the stream is at end-of-file, if a read error occurs, or if an encoding error occurs.

Remarks

This function advances the associated file position indicator for stdin (if defined) and sets the end-of file indicator when the end-of-file is reached. If a read error occurs, the error indicator for stdin is set and can be checked with the ferror() function. If an encoding error occurs (which includes too few bytes), errno is set to the value of the EILSEQ macro.

Example

#include <wchar.h>

int main(void)
{
  wint_t wc;

  while( ! feof(stdin)) {
    wc = getwchar();
    if(iswprint(wc))
      wprintf(L"char read: %lc\n", wc);
  }
}

Example Input

Present on stdin.

hi there

Example Output

char read: h
char read: i
char read:  
char read: t
char read: h
char read: e
char read: r
char read: e