C Standard Library

C <wctype.h> - WEOF Constant

The C <wctype.h> WEOF is a macro constant definition of type wint_t that expands into a constant expression whose value does not correspond to any character of wide character set.

It is used as the value returned by several wide character functions to indicate either the End-of-File has been reached, or to indicate a character value not corresponding to any member of the wide character set.

This macro constant is also defined in header <wchar.h>.


The example below shows one of the usage of WEOF macro constant.

#include <wchar.h>
#include <wctype.h>
void try_widen(unsigned char c) {
  //wint_t type is used to hold the character 
  //value of the wide character set
  wint_t wc = btowc(c);
  //WEOF is used to check whether the widening of 
  //character was successful or not
  if(wc != WEOF)
    wprintf(L"Single-byte character %#x widens to %#x\n", c, wc);
    wprintf(L"Single-byte character %#x failed to widen\n", c);

int main (){
  return 0;

The output of the above code will be:

Single-byte character 0x41 widens to 0x41
Single-byte character 0x9 widens to 0x9
Single-byte character 0xf9 failed to widen
Single-byte character 0xdf failed to widen

❮ C <wctype.h> Library