淡泊明志 宁静致远
分类: C/C++
2006-12-10 14:13:58
【C语言库函数源代码】
【本程序在Dev C++ 4.9.9.2 下编译通过】
int my_isprint( int ch )
{
return (unsigned int)(ch - '
') < 127u - ' ';
}//判断字符c是否为可打印字符(含空格)。当c为可打印字符(0x20-0x7e)时,返回非零值,否则返回零。
int main()
{
char ch =
'_';
if(my_isprint(ch))
printf("%c is a Sprint
Character\n",ch);
else
printf("%c is not a Sprint
Character!\n",ch);
ch = '1';
if(my_isprint(ch))
printf("%c is a Sprint
Character\n",ch);
else
printf("%c is not a Sprint
Character!\n",ch);
ch = 0x10;
if(my_isprint(ch))
printf("0x%x is a Sprint
Character\n",ch);
else
printf("0x%x is not a Sprint
Character!\n",ch);
system("pause");
return 0;
}