std::isalpha

Header: <cctype>

Checks if the given character is an alphabetic character as classified by the currently installed C locale. In the default locale, the following characters are alphabetic:

# Declarations

int isalpha( int ch );

# Parameters

# Return value

Non-zero value if the character is an alphabetic character, zero otherwise.

# Notes

Like all other functions from , the behavior of std::isalpha is undefined if the argument’s value is neither representable as unsigned char nor equal to EOF. To use these functions safely with plain chars (or signed chars), the argument should first be converted to unsigned char:

Similarly, they should not be directly used with standard algorithms when the iterator’s value type is char or signed char. Instead, convert the value to unsigned char first:

# Example

#include <cctype>
#include <clocale>
#include <iostream>
 
int main()
{
    unsigned char c = '\xdf'; // German letter ß in ISO-8859-1
 
    std::cout << "isalpha(\'\\xdf\', default C locale) returned "
              << std::boolalpha << !!std::isalpha(c) << '\n';
 
    std::setlocale(LC_ALL, "de_DE.iso88591");
    std::cout << "isalpha(\'\\xdf\', ISO-8859-1 locale) returned "
              << static_cast<bool>(std::isalpha(c)) << '\n';
 
}

# See also