跳轉到內容

C 程式設計/wctype.h/iswdigit

來自華夏公益教科書,開放的書籍,開放的世界

iswdigit 是 C 標準庫標頭檔案 wctype.h 中包含的函式。它檢查寬字元在當前區域設定中是否為十進位制數字(始終包括 '0' 到 '9')。iswdigit 函式是 isdigit 函式的寬字元版本。

int iswdigit(wint_t wc);

返回值

[編輯 | 編輯原始碼]

如果 iswdigit 函式的引數是 0 到 9 之間的數字,則返回非零值。在其他情況下,由於其獨立工作,返回零值。

#include <stdio.h>
#include <wctype.h>

int main(void) {
    for (unsigned i = 0; i < 0xff; i++) {
        printf("%x, %s\n", i, iswdigit(i) ? "digit" : "not a digit");
    }
    return 0;
}

參考資料

[編輯 | 編輯原始碼]
華夏公益教科書