C++ iswdigit()

The iswdigit() function in C++ checks if the given wide character is a digit or not.

The iswdigit() function is defined in <cwctype> header file.

iswdigit() prototype

int iswdigit(wint_t ch);

The iswalnum() function checks if ch is a digit or not. The characters from 0 to 9 i.e. 0,1,2,3,4,5,6,7,8,9 are classified as digits.

iswdigit() Parameters

  • ch: The wide character to check.

iswdigit() Return value

  • The iswdigit() function returns non zero value if ch is a digit.otherwise returns zero.
  • It returns zero if ch is not a digit.

Example: How iswdigit() function works?

#include <cwctype>
#include <iostream>
#include <cwchar>
#include <clocale>
using namespace std;

int main()
	setlocale(LC_ALL, "en_US.UTF-8");
	wchar_t str[] = L"\u20b9\u0967\u0966 = Rs.10";

	wcout << L"The digit in the string \"" << str << L"\" are :" << endl;
	for (int i=0; i<wcslen(str); i++)
		if (iswdigit(str[i]))
		wcout << str[i] << " ";
	return 0;

When you run the program, the output will be:

The digit in the string "₹१० = Rs.10" are :
1 0
Did you find this article helpful?