
- The C Standard Library
- C Library - Home
- C Library - <assert.h>
- C Library - <complex.h>
- C Library - <ctype.h>
- C Library - <errno.h>
- C Library - <fenv.h>
- C Library - <float.h>
- C Library - <inttypes.h>
- C Library - <iso646.h>
- C Library - <limits.h>
- C Library - <locale.h>
- C Library - <math.h>
- C Library - <setjmp.h>
- C Library - <signal.h>
- C Library - <stdalign.h>
- C Library - <stdarg.h>
- C Library - <stdbool.h>
- C Library - <stddef.h>
- C Library - <stdio.h>
- C Library - <stdlib.h>
- C Library - <string.h>
- C Library - <tgmath.h>
- C Library - <time.h>
- C Library - <wctype.h>
- C Standard Library Resources
- C Library - Quick Guide
- C Library - Useful Resources
- C Library - Discussion
- C Programming Resources
- C Programming - Tutorial
- C - Useful Resources
C Library - isalpha() Function
The C ctype library isalpha() function is used to check if a given character is an alphabetic letter or not. If argument c is not an alphabetic letter, the function returns 0 (false).
Syntax
Following is the C library syntax of the isalpha() function −
int isalpha(int c);
Parameters
This function accepts a single parameter −
c − This is the character to be checked, passed as an int. The value of c must be representable as an unsigned char or must be equal to EOF.
Return Value
The function returns a non-zero value (true) if the character c is an alphabetic letter (either uppercase or lowercase), which means it falls within the ranges A to Z or a to z.
Example 1: Checking a Single Alphabetic Character
We will take a alphabetic letter form the Character set A-Z and then check if the letter is recognized as an alphabet or not by isalpha() function.
#include <stdio.h> #include <ctype.h> int main() { char c = 'A'; if (isalpha(c)) { printf("%c is an alphabetic character.\n", c); } else { printf("%c is not an alphabetic character.\n", c); } return 0; }
Output
The above code produces following result −
A is an alphabetic character.
Example 2: Checking a special character
In this example, we check if a special character is also recognized as a alphabetic character or not.
#include <stdio.h> #include <ctype.h> int main() { char c = '@'; if (isalpha(c)) { printf("%c is an alphabetic character.\n", c); } else { printf("%c is not an alphabetic character.\n", c); } return 0; }
Output
The above code produces following result −
@ is not an alphabetic character.