原型:extern int isalnum(int c); 用法:#include <ctype.h> 功能:判断字符c是否为字母或数字 说明:当c为数字0-9或字母a-z及A-Z时,返回非零值,否则返回零。 举例: // isalnum.c #include <syslib.h> #include <ctype.h> main() { int c; clrscr(); // clear screen c='a'; printf("%c:%s/n",c,isalnum(c)?"yes":"no"); c='7'; printf("%c:%s/n",c,isalnum(c)?"yes":"no"); c='@'; printf("%c:%s/n",c,isalnum(c)?"yes":"no"); getchar(); return 0; }
----------------------------------------
Example
/* 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; }
Output:
The first 4 characters are alphanumeric.
---------------------------------------------