getwc


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( )



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net