ฟังก์ชัน iswdigit() เป็นฟังก์ชันสำเร็จรูปใน C/C++ ใช้ตรวจสอบว่าตัวอักษรกว้าง (wide character) เป็นตัวเลขฐานสิบ (0-9) หรือไม่ ประกาศอยู่ในไฟล์ส่วนหัว cwctype (C++) หรือ ctype.h (C)
คืนค่า 0 หากไม่ใช่ตัวเลข และคืนค่าที่ไม่ใช่ 0 หากเป็นตัวเลข
รูปแบบไวยากรณ์
int iswdigit(wint_t ch)
ตัวอย่าง
#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