cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : C Library : cctype (ctype.h) : isalpha
 
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
C Library
cassert (assert.h)
cctype (ctype.h)
cerrno (errno.h)
cfloat (float.h)
climits (limits.h)
clocale (locale.h)
cmath (math.h)
csetjmp (setjmp.h)
csignal (signal.h)
cstdarg (stdarg.h)
cstddef (stddef.h)
cstdio (stdio.h)
cstdlib (stdlib.h)
cstring (string.h)
ctime (time.h)
cctype (ctype.h)
isalnum
isalpha
iscntrl
isdigit
isgraph
islower
isprint
ispunct
isspace
isupper
isxdigit
tolower
toupper

-

isalpha function
int isalpha ( int c );
<cctype>

Check if character is alphabetic

Checks if parameter c is either an uppercase or a lowercase alphabetic letter.

Notice that what is considered a letter may depend on the locale being used; In the default C locale, what constitutes a letter is what returns true by either isupper or islower.

For a detailed chart on what the different ctype functions return for each character of the standard ANSII character set, see the reference for the <cctype> header.

Parameters

c
Character to be checked, casted to an int, or EOF.

Return Value

A value different from zero (i.e., true) if indeed c is an alphabetic letter. Zero (i.e., false) otherwise.

Example

/* isalpha example */
#include <stdio.h>
#include <ctype.h>
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

See also

isalnum Check if character is alphanumeric (function)
isdigit Check if character is decimal digit (function)
© The C++ Resources Network, 2000-2007 - All rights reserved
Spotted an error? - contact us