C Library Functions -isalpha()
C Standard Library - <ctype.h>
Description
C Library Functionsvoid isalpha(int c)Checks whether the character passed is a letter.
Declaration
Below is the declaration of the isalpha() function.
int isalpha(int c);
Parameter
- c-- This is the character to be checked.
Return Value
If c is a letter, the function returns a non-zero value; otherwise, it returns 0.
Example
The following example demonstrates the usage of the isalpha() function.
#include <stdio.h>
#include <ctype.h>
int main()
{
int var1 = 'd';
int var2 = '2';
int var3 = '\t';
int var4 = ' ';
if( isalpha(var1) )
{
printf("var1 = |%c| 是一个字母\n", var1 );
}
else
{
printf("var1 = |%c| 不是一个字母\n", var1 );
}
if( isalpha(var2) )
{
printf("var2 = |%c| 是一个字母\n", var2 );
}
else
{
printf("var2 = |%c| 不是一个字母\n", var2 );
}
if( isalpha(var3) )
{
printf("var3 = |%c| 是一个字母\n", var3 );
}
else
{
printf("var3 = |%c| 不是一个字母\n", var3 );
}
if( isalpha(var4) )
{
printf("var4 = |%c| 是一个字母\n", var4 );
}
else
{
printf("var4 = |%c| 不是一个字母\n", var4 );
}
return(0);
}
Let us compile and run the above program, which will produce the following result:
var1 = |d| 是一个字母 var2 = |2| 不是一个字母 var3 = | | 不是一个字母 var4 = | | 不是一个字母other extensions