C/C++ 中的 iswdigit() 函数
iswdigit() 函数是 C/C++ 中的内置函数。它检查宽字符是否是十进制数字。它在 C++ 语言中声明在“cwctype”头文件中,而在 C 语言中声明在“ctype.h”头文件中。它接收一个称为宽字符的单个字符。
0 到 9 之间的字符被归类为十进制数字。如果宽字符不是十进制数字,它将返回零 (0)。如果字符是数字,它将返回非零值。
以下是在 C++ 语言中 iswdigit() 的语法:
int iswdigit(ch)
以下是在 C++ 语言中 iswdigit() 的一个示例:
示例
#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
广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP