Facebook Page Twitter Page LinkedIn Page
× C Standard Library


The C <wctype.h> wint_t is an integer type that can hold any valid wide character and at least one more value (that corresponds to WEOF).

Some functions use this type to represent either a character of the wide character set or WEOF. This may be the same type as wchar_t or different depending on the system characteristics and library implementation.

This type is also defined in header <wchar.h>.

Example:

The below example shows the usage of wint_t type.

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

int main (){
  try_widen('A');
  try_widen('\t');
  try_widen(0xf9);
  try_widen(0xdf);
  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