C examples for wchar.h:fgetwc
function
<cwchar> <wchar.h>
Get wide character from stream
wint_t fgetwc (FILE * stream);
Parameter | Description |
---|---|
stream | Pointer to a FILE object |
On success, the character read is returned.
#include <stdio.h> #include <wchar.h> int main ()/*w w w .j av a 2s . c o m*/ { FILE * pFile; wint_t wc; int n = 0; pFile=fopen ("main.cpp","r"); if (pFile == NULL){ perror("cannot open file"); return -1; } do { wc = fgetwc (pFile); if (wc == L'$') n++; } while (wc != WEOF); fclose (pFile); wprintf (L"The file contains %d dollar sign characters ($).\n",n); return 0; }