6.3.2 isalpha Function

Test for an alphabetic character.

Include

<ctype.h>

Prototype

int isalpha(int c);

Argument

c
The character to test.

Return Value

Returns a non-zero integer value if the character is alphabetic; otherwise, returns zero.

Remarks

Alphabetic characters are included within the ranges 'A'-'Z' or 'a'-'z'.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

#include <ctype.h>
#include <stdio.h>

int main(void)
{
  int ch;

  ch = 'B';
  if (isalpha(ch))
    printf("B is alphabetic\n");
  else
    printf("B is NOT alphabetic\n");

  ch = '#';
  if (isalpha(ch))
    printf("# is alphabetic\n");
  else
    printf("# is NOT alphabetic\n");
}

Example Output

B is alphabetic
# is NOT alphabetic