C isalpha function checks whether a character is a letter or not

Syntax

C isalpha function has the following syntax.

int isalpha(int ch);

C isalpha function is the header file ctype.h.

Description

C isalpha function returns nonzero if ch is a letter or zero if not.

Example

The following code uses C isalpha function to check if a character is a letter. The letter is read from the console.


#include <ctype.h>
#include <stdio.h>
// w  w  w.ja v a 2 s .co  m
int main(void)
{
  char ch;

  for(;;) {
     ch = getchar();
     if(ch == '.') {
        break;
     }
     if(isalpha(ch)) {
        printf("%c is a letter\n", ch);
     }
  }

  return 0;
}

The code above generates the following result.





















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h