int isalnum(int c);
引數 c 表示要檢測字元或者 ASCII 碼。#include <stdio.h> #include <ctype.h> int main() { int i = 0, n = 0; char str[] = "*http://c.biancheng.net is 7 years old"; while (str[i]) { if (isalnum(str[i])) n++; i++; } printf("There are %d characters in str is alphanumeric.n", n); return 0; }執行結果: