C examples for wchar.h:wctob
function
<cwchar> <wchar.h>
Convert wide character to single byte
int wctob (wint_t wc);
Parameter | Description |
---|---|
wc | a wide character. |
On success, the function returns an unsigned char.
Otherwise, it returns EOF.
#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; }