wctype() function in C/C++ Last Updated : 04 Sep, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The wctype() is a built-in function in C/C++ which returns a value of type wctype_t that is used for classifying a wide character. It is defined within the cwctype header file of C++. The following are the possible type wctype_t: Value of str Equivalent function space iswspace upper iswupper xdigit iswxdigit print iswprint punct iswpunct graph iswgraph lower iswlower cntrl iswcntrl digit iswdigit alpha iswalpha blank iswblank alnum iswalnum Syntax: wctype_t wctype(const char* str) Parameter: The function accepts a single mandatory parameter str which specifies the desired wctype category. Return Value: The function returns two values as shown below: The function returns a wctype_t object that can be used with iswctype() ortowctype() to check a wide character's property. If str doesn't provide a category supported by the current C locale, it returns zero. Below programs illustrates the above function. Program 1: CPP #include <bits/stdc++.h> using namespace std; int main() { wchar_t wc = L'@'; // checks if the type is digit if (iswctype(wc, wctype("digit"))) wcout << wc << L" is a digit"; // checks if the type is alpha else if (iswctype(wc, wctype("alpha"))) wcout << wc << L" is an alphabet"; else wcout << wc << L" is neither an" << " alphabet nor a digit"; return 0; } Output: @ is neither an alphabet nor a digit Output: @ is neither an alphabet nor a digit Program 2: CPP #include <bits/stdc++.h> using namespace std; int main() { wchar_t wc = L'g'; // checks if the type is digit if (iswctype(wc, wctype("digit"))) wcout << wc << L" is a digit"; // checks if the type is alpha else if (iswctype(wc, wctype("alpha"))) wcout << wc << L" is an alphabet"; else wcout << wc << L" is neither" << " an alphabet nor a digit"; return 0; } Output: g is an alphabet Comment More infoAdvertise with us Next Article wcstoul() function in C/C++ R rupesh_rao Follow Improve Article Tags : C++ CPP-Functions C-Library Practice Tags : CPP Similar Reads iswctype() function in C/C++ The iswctype() is a built-in function in C/C++ which checks if a given wide character has a certain property. It is defined within the cwctype header file of C/C++ Syntax: int iswctype(wint_t wc, wctype_t desc) Parameter: The function accepts two mandatory parameter which are described below: wc - T 2 min read wcstol() function in C/C++ The wcstol() function in C/C++ converts the given wide string to a long integer. This function sets a pointer to point to the first character after the last valid character of the wide string if there is any, otherwise, the pointer is set to null. This function ignores all the leading whitespace cha 3 min read wcstod() function in C/C++ The wcstod() function converts the wide string as a double. This function interprets the contents of a wide string as a floating point number. If endString is not a null pointer, the function also sets the value of endString to point to the first character after the number. Syntax: double wcstod( co 3 min read wcsncmp() function in C/C++ The wcsncmp() function in C/C++ compare characters of two wide strings. The comparison is done lexicographically. This function takes three arguments lhs, rhs and count. It compares the contents of lhs and rhs lexicographically upto a maximum of count wide characters. Note: The behaviour of wcsncmp( 3 min read wcstoul() function in C/C++ The wcstoul() function in C/C++ converts a wide string to an unsigned long integer of the specified base. It sets a pointer to point to the first character after the last valid character of the wide string if there is any, otherwise, the pointer is set to null. It ignores all the leading whitespace 4 min read wcrtomb() function in C/C++ The wcrtomb() function in C/C++ converts a wide character to its narrow multibyte representation. The wide character wc is translated to its multibyte equivalent and stored in the array pointed by s. The function returns the length in bytes of the equivalent multibyte sequence pointed by s. Syntax : 3 min read Like