这个 iswdigit() 是C++中的一个内置函数,它检查给定的宽字符是否为十进制数字字符。它是在 cwctype C++的头文件。从0到9的字符,即0、1、2、3、4、5、6、7、8、9被归类为十进制数字。
null
语法 :
int iswdigit(ch)
参数 :该函数接受一个强制参数 中国 它指定了宽字符,我们必须检查它是否是数字。
返回值 :该函数返回两个值,如下所示。
- 如果ch是一个数字,则返回一个非零值。
- 如果不是,则返回0。
下面的程序说明了上述功能。
方案1 :
// C++ program to illustrate // iswdigit() function #include <cwctype> #include <iostream> using namespace std; int main() { wchar_t ch1 = '?' ; wchar_t ch2 = '3' ; // Function to check if the character // is a digit or not if (iswdigit(ch1)) wcout << ch1 << " is a digit " ; else wcout << ch1 << " is not a digit " ; wcout << endl; if (iswdigit(ch2)) wcout << ch2 << " is a digit " ; else wcout << ch2 << " is not a digit " ; return 0; } |
输出:
? is not a digit 3 is a digit
方案2 :
// C++ program to illustrate // iswdigit() function #include <cwctype> #include <iostream> using namespace std; int main() { wchar_t ch1 = '1' ; wchar_t ch2 = 'q' ; // Function to check if the character // is a digit or not if (iswdigit(ch1)) wcout << ch1 << " is a digit " ; else wcout << ch1 << " is not a digit " ; wcout << endl; if (iswdigit(ch2)) wcout << ch2 << " is a digit " ; else wcout << ch2 << " is not a digit " ; return 0; } |
输出:
1 is a digit q is not a digit
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END