isdigit
原型:extern int isdigit(int c); 用法:#include 功能:判断字符c是否为数字 说明:当c为数字0-9时,返回非零值,否则返回零。 举例: // isdigit.c #include #include main() { int c; clrscr(); // clear screen c='a'; printf("%c:%s/n",c,isdigit(c)?"yes":"no"); c='9'; printf("%c:%s/n",c,isdigit(c)?"yes":"no"); c='*'; printf("%c:%s/n",c,isdigit(c)?"yes":"no"); getchar(); return 0; }
------------------
Example
/* isdigit example */ #include #include #include int main () { char str[]="1776ad"; int year; if (isdigit(str[0])) { year = atoi (str); printf ("The year that followed %d was %d./n",year,year+1); } return 0; }