isalpha函数使用

来源:互联网 发布:小学生网络字典 编辑:程序博客网 时间:2024/06/12 21:40
原型:extern int isalpha(int c);

用法:#include <ctype.h>

功能:判断字符c是否为英文字母

说明:当c为英文字母a-z或A-Z时,返回非零值,否则返回零。

举例:

// isalpha.c

#include <syslib.h>
#include <ctype.h>
#include <stdio.h>

main()
{
int c;

clrscr(); // clear screen
printf("Press a key");
for(;;)
{
c=getchar();
clrscr();
printf("%c: %s letter",c,isalpha(c)?"is":"not");
}
return 0;// just to avoid warnings by compiler
}

相关函数:isalnum,isdigit,isxdigit,iscntrl,isgraph,isprint,ispunct,isspace
原创粉丝点击