1. 程式人生 > >isdigit 函式

isdigit 函式

原型:extern int isdigit(int c);

用法:#include <ctype.h>

功能:判斷字元c是否為數字

說明:當c為數字0-9時,返回非零值,否則返回零。

舉例:

      // isdigit.c
      #include <syslib.h>
      #include <ctype.h>

      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;
      }