Name

isalpha - character classification routines

Library

libc.lib

Synopsis

  #include <ctype.h>
  int isalpha (int c);

Return values

The isalpha function returns non-zero if the character is an alphabet and zero otherwise.

Detailed description

The isalpha function returns non-zero if ’c’ is an alphabet i.e. it belongs to class alpha (see defns for definition). In other words, it returns non-zero if the test for isupper or islower is non-zero,irrespective of the program’s current locale. The function will return non-zero for also those characters that are alphabets and cannot be categorised as upper or lower case. For single character representations, the value of the argument is representable as an unsigned char or the value of EOF.

The functionality of this API is independent of the program’s current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class alpha,
irrespective of the locale they belong to.


Examples

#include<ctype.h> //isalpha()
#include<stdio.h> //printf()
void test_isalpha()
{
   int arr[]={’a’,0xe1,’5’,’Z’,0xfd};
   int i = 0;
   int size = 5;
   for( i=0; i<size; i++)
   {
      int ret = isalpha(arr[i]); //call to the API with chars in arr[]
      if( (!ret) != 0 )
      {
        printf("\n%c is not an alphabet", arr[i]);
      }
      else
      {
        printf("\n%c is an alphabet", arr[i]);
      }
   }
   printf("\n");
}

         

Output

a is an alphabet
á is an alphabet
5 is not an alphabet
Z is an alphabet
ý is an alphabet

         

See also

islower, isupper, iswalpha

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top