fgetwc reads in a single character from Stream and returns its value as a wide character.
/* * fgetwc example code * http://code-reference.com/c/wchar.h/fgetwc */ #include <stdio.h> /* including standard library */ //#include <windows.h> /* uncomment this for Windows */ #include <wchar.h> int main( void ) { FILE* stream = fopen("testmb.txt", "r"); if (!stream) { printf("Could not open the file\n"); return 1; } wchar_t wchar = fgetwc(stream); if (wchar != WEOF) { printf("char read: %c\n", wchar); } else { printf("read error\n"); } fclose(stream); return 0; }
A B C
A