totn C Functions

C Language: isalpha function
(Test for Alphabetic)

In the C Programming Language, the isalpha function tests whether c is alphabetic.

Syntax

The syntax for the isalpha function in the C Language is:

int isalpha(int c);

Parameters or Arguments

c
The value to test whether it is alphabetic.

Note

Returns

The isalpha function returns a nonzero value if c is alphabetic and returns zero if c is not alphabetic.

Required Header

In the C Language, the required header for the isalpha function is:

#include <ctype.h>

Applies To

In the C Language, the isalpha function can be used in the following versions:

  • ANSI/ISO 9899-1990

isalpha Example

/* Example using isalpha by TechOnTheNet.com */

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

int main(int argc, const char * argv[])
{
    /* Define a temporary variable */
    unsigned char test;

    /* Assign a test letter to the variable */
    test = 'T';

    /* Test to see if this is a alphabet character */
    if (isalpha(test) != 0) printf("%c is in the alphabet\n", test);
    else printf("%c is not in the alphabet\n", test);

    /* Assign a non-alphabetic character to the variable */
    test = '7';

    /* Test to see if this is a alphabet character */
    if (isalpha(test) != 0) printf("%c is in the alphabet\n", test);
    else printf("%c is not in the alphabet\n", test);

    return 0;
}

When compiled and run, this application will output:

T is in the alphabet
7 is not in the alphabet

Similar Functions

Other C functions that are similar to the isalpha function:

See Also

Other C functions that are noteworthy when dealing with the isalpha function: