C / C ++中的iswdigit()函数
该函数iswdigit()是C/C++中的内置函数。它检查宽字符是否为十进制数字。在C++语言中的“cwctype”头文件中声明,而在C语言中的“ctype.h”中声明。它采用单个字符,称为宽字符。
从0到9的字符被分类为十进制数字。如果宽字符不是数字,它将返回零。如果字符是数字,它将返回非零值。
这是iswdigit()C++语言的语法,
int iswdigit(ch)
这是iswdigit()C++语言的示例,
示例
#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;
}输出结果
! , The character is not a digit 8 , The character is a digit