函式
<cctype>

isalnum

int isalnum ( int c );
檢查字元是否為字母或數字
檢查c是十進位制數字還是大寫或小寫字母。

如果isalphaisdigit也返回true,則結果為true。

請注意,什麼被視作字母可能取決於所使用的區域設定;在預設的"C"區域設定,構成字母的是isupperislower返回true的內容。

有關不同ctype函式為標準 ANSII 字元集中的每個字元返回的值,請參閱 <cctype> 標頭檔案的參考。

在C++中,此函式的特定於區域設定的模板版本(isalnum)存在於標頭檔案<locale>中。

引數

c
要檢查的字元,已轉換為int型別,或EOF.

返回值

如果 c 確實是空白字元,則返回一個非零值(即true) 如果c確實是數字或字母。零(即false)。

示例

1
2
3
4
5
6
7
8
9
10
11
12
/* isalnum example */
#include <stdio.h>
#include <ctype.h>
int main ()
{
  int i;
  char str[]="c3po...";
  i=0;
  while (isalnum(str[i])) i++;
  printf ("The first %d characters are alphanumeric.\n",i);
  return 0;
}

輸出
The first 4 characters are alphanumeric.


另見