WEOF - C wchar.h

C examples for wchar.h:WEOF

Type

constant

From


<cwchar>
<wchar.h>
<cwctype>

Description

Wide end-of-file

Demo Code


#include <stdio.h>
#include <wchar.h>

int main ()/*from   ww w . ja v a  2 s . c om*/
{
  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;
}

Related Tutorials