isascii ( )【C语言库函数源代码】

来源:互联网 发布:宾馆住宿客房软件 编辑:程序博客网 时间:2024/06/09 14:55

C语言库函数源代码】

【本程序在Dev C++ 4.9.9.2 下编译通过】

int my_isascii( int ch )

{

   return (unsigned int)ch < 128u;

}//判断字符c是否为ascii码。ascii码指0x00-0x7F之间的字符。

int main()

{

   int ch = 'a';

 

   if(my_isascii(ch))

      printf("%c is ASCII Character!/n",ch);

   else

      printf("%c is not a ASCII Character!/n",ch);

 

   ch = 0x80;

 

   if(my_isascii(ch))

      printf("0x%x is ASCII Character!/n",ch);

   else

      printf("0x%x is not a ASCII Character!/n",ch);

 

   system("pause");

   return 0;

}