Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C Library Function - isalpha()

C Library Function - isalpha()

C Standard Library - <ctype.h> C Standard Library -

Description

C Library Function void isalpha(int c) Check whether the passed character is a letter.

Declaration

Below is the declaration of the isalpha() function.



int isalpha(int c);

Parameters

Return Value

If c is a letter, the function returns a nonzero value; otherwise, it returns 0.

Example

The following example demonstrates the use of the isalpha() function.



#include 

#include 



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's compile and run the above program, which will produce the following result:



var1 = |d| 是一个字母

var2 = |2| 不是一个字母

var3 = | | 不是一个字母

var4 = | | 不是一个字母

C Standard Library - <ctype.h> C Standard Library -