Iswctype() function in C++ STL


In C++ standard template libraray(STL), iswctype() function is used to check if the given wide character has property specified by desc.

Iswctype() is an in built function whose header file is “ctype.h”.

Syntax of Iswctype() is as follows

int iswctype(wint_t c, wctype_t desc);
iswctype ()
/ Checks whether whether c has the property specified by desc. /

Synopsis

int iswctype(wint_t c, wctype_t desc);

Parameters

C − To check the wide characters which are casted to the integral type wint_t

Desc − It is a value which is returned by the call to wctype, which is a scalar type which is used as return type for wctype(Wide character type).

Return Value

A value different from zero (i.e., true) if indeed c is has the property identified by desc. Zero (i.e., false) otherwise.

PROGRAM FOR ISWCTYPE () FUNCTION IN C

 Live Demo

#include <stdio.h>
#include <wctype.h>
int main (){
   int i=0;
   wchar_t str[] = L"Test String.\n";
   wchar_t c;
   wctype_t check = wctype("lower");
   wctrans_t trans = wctrans("toupper");
   while (str[i]){
      c = str[i];
      if (iswctype(c,check)) c = towctrans(c,trans);
         putwchar (c);
         i++;
   }
   return 0;
}

Output

If we run the above code it will generate the following output −

TEST STRING.

Updated on: 30-Jan-2020

33 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements