iswdigit() function in C/C++


The function iswdigit() is a built-in function in C/C++. It checks whether the wide character is a decimal digit or not. It is declared in “cwctype” header file in C++ language while “ctype.h” in C language. It takes a single character which is known as wide character.

The characters from 0 to 9 are classified as decimal digits. If the wide character is not a digit, it will return zero(0). If character is digit, it will return non-zero value.

Here is the syntax of iswdigit() in C++ language,

int iswdigit(ch)

Here is an example of iswdigit() in C++ language,

Example

 Live Demo

#include <cwctype>
#include <iostream>
using namespace std;
int main() {
   wchar_t c1 = '!';
   wchar_t c2 = '8';
   if (iswdigit(c1))
   wcout << c1 << " , The character is a digit ";
   else
   wcout << c1 << " , The character is not a digit ";
   wcout << endl;
   if (iswdigit(c2))
   wcout << c2 << ", The character is a digit ";
   else
   wcout << c2 << ", The character is not a digit ";
   return 0;
}

Output

! , The character is not a digit
8 , The character is a digit

Updated on: 24-Jun-2020

157 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements