Previous Page
Next Page

getwc

Reads a wide character from a file

#include <stdio.h>
#include <wchar.h>
wint_t getwc ( FILE *fp  );

The getwc( ) function is the wide-character counterpart to getc( ): it may be implemented as a macro, and may evaluate its argument more than once, causing unforeseen side effects. Use fgetwc( ) instead.

getwc( ) returns the character read. A return value of WEOF indicates an error or an attempt to read past the end of the file.

Example

wint_t wc;

if ( setlocale( LC_CTYPE, "" ) == NULL)
{
  fwprintf( stderr,
            L"Sorry, couldn't change to the system's native locale.\n");
  return 1;
}
while ( (wc = getwc( stdin)) != WEOF )
{
  wc = towupper(wc);
  putwc( (wchar_t)wc, stdout);
}

See Also

The function fgetwc( ); the corresponding output functions putwc( ) and fputwc( ); the byte-character functions getc( ) and getchar( ); the byte-character output functions putc( ), putchar( ), and fputc( )


Previous Page
Next Page