wctob - C wchar.h

C examples for wchar.h:wctob

Type

function

From


<cwchar>
<wchar.h>

Description

Convert wide character to single byte

Prototype

int wctob (wint_t wc);

Parameters

Parameter Description
wc a wide character.

Return Value

On success, the function returns an unsigned char.

Otherwise, it returns EOF.

Demo Code


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

int main()//w ww.  j  ava  2s . c  o m
{
  int i,num;
  const wchar_t wcs [] = L"this is a test \n \t \a";

  num=0;
  for (i=0; i<wcslen(wcs); ++i)
    if (wctob(wcs[i]) != EOF) 
       ++num;

  wprintf (L"wcs contains %d characters.",num);

  return 0;
}

Related Tutorials