C++ Standard Library C++ STL Library

C++ <cwctype> - iswdigit() Function



The C++ <cwctype> iswdigit() function is used to check if the given wide character is a decimal digit or not. Decimal digits are one of the 10 digits: 0123456789.

Syntax

int iswdigit ( wint_t ch );               

Parameters

ch Specify the wide character to be checked, casted to an wint_t, or WEOF.

Return Value

Returns non-zero value (i.e, true) if ch is a decimal digit, else returns zero (i.e, false).

Example:

The example below shows the usage of iswdigit() function.

#include <iostream>
#include <cwchar>
#include <cwctype>
using namespace std;
 
int main (){
  wchar_t str[50] = L"980Alpha55";

  //counting the numbers of 
  //decimal digits in str
  int i = 0, count = 0;
  while(str[i]) {
    if(iswdigit(str[i]))
      count++;
    i++;
  }

  //displaying the output
  wcout<<str<<" contains "<<count<<
       " decimal digits.";  
  return 0;
}

The output of the above code will be:

980Alpha55 contains 5 decimal digits.

❮ C++ <cwctype> Library