函式
<cwctype>

iswdigit

int iswdigit (wint_t c);
檢查寬字元是否為十進位制數字
檢查 c 是否為十進位制數字字元

十進位制數字是以下任意一個0 1 2 3 4 5 6 7 8 9

此函式是 isdigit (<cctype>) 的寬字元等效函式:如果 c 可以透過 wctob 轉換為一個使 isdigit 返回 true 的字元,那麼該函式也始終認為它是一個十進位制數字字元。

在 C++ 中,此函式的一個針對區域設定的模板版本 (isdigit) 存在於標頭檔案 <locale> 中,適用於所有字元型別。

引數

c
要檢查的寬字元,強制轉換為wint_t型別,或WEOF.
wint_t 是一個整數型別。

返回值

如果 c 確實是空白字元,則返回一個非零值(即true),如果 c 確實是一個十進位制數字。否則返回零 (即false)。

示例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* iswdigit example */
#include <stdio.h>
#include <wchar.h>
#include <wctype.h>
int main ()
{
  wchar_t str[] = L"1776ad";
  long int year;
  if (iswdigit(str[0]))
  {
    year = wcstol (str,NULL,10);
    wprintf (L"The year that followed %ld was %ld.\n",year,year+1);
  }
  return 0;
}

輸出
The year 1777 followed 1776


另見