原型:extern int isalpha(int c);
用法:#include
功能:判断字符c是否为英文字母
说明:当c为英文字母a-z或A-Z时,返回非零值,否则返回零。
举例:
// isalpha.c
#include
#include
#include
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
}
--------------------------------------------
Example
/* isalpha example */ #include #include int main () { int i=0; char str[]="C++"; while (str[i]) { if (isalpha(str[i])) printf ("character %c is alphabetic/n",str[i]); else printf ("character %c is not alphabetic/n",str[i]); i++; } return 0; }
Output:
character C is alphabetic
character + is not alphabetic
character + is not alphabetic
-----------------------------------------