淡泊明志 宁静致远
分类: C/C++
2006-12-10 14:32:00
【C语言库函数源代码】
【本程序在Dev C++ 4.9.9.2 下编译通过】
int my_iscntrl( int ch )
{
return (unsigned int)ch <
32u ||
ch == 127;
}//判断字符c是否为控制字符。当c在0x00-0x1F之间或等于0x7F(DEL)时,返回非零值,否则返回零。
int main()
{
char ch =
'_';
if(my_iscntrl(ch))
printf("%c is a Ctrol
Character\n",ch);
else
printf("%c is not a Ctrol
Character!\n",ch);
ch = 0x10;
if(my_iscntrl(ch))
printf("0x%x is a Ctrol
Character\n",ch);
else
printf("0x%x is not a Ctrol
Character!\n",ch);
ch = ' ';
if(my_iscntrl(ch))
printf("%c is a Ctrol
Character\n",ch);
else
printf("%c is not a Ctrol
Character!\n",ch);
system("pause");
return 0;
}