CKTIS / C
isalpha — C23 character classification function
`isalpha(c)` from `<ctype.h>` returns a nonzero value for an alphabetic character in the current locale. In the `C` locale these are characters accepted by `isupper` or `islower`; another locale can add letters that are not control characters, digits, punctuation, or whitespace.
Version: C23
Syntax
int isalpha(int c);isalpha(c) from <ctype.h> returns a nonzero value for an alphabetic character in the current locale. In the C locale these are characters accepted by isupper or islower; another locale can add letters that are not control characters, digits, punctuation, or whitespace.
The example tests A, z, 7, and - in the initial C locale and normalizes each result with != 0. Output 1 1 0 0 shows that both letters pass, whereas the digit and hyphen do not.
The only valid arguments are EOF and values representable as unsigned char; a negative plain char causes undefined behavior. Write isalpha((unsigned char)ch) for a byte, but do not cast EOF. The function classifies single-byte characters under LC_CTYPE, not full Unicode code points; an explicit ASCII range is often better for protocol identifiers.
Examples
#include <ctype.h>
#include <stdio.h>
int main(void){int values[]={'A','z','7','-'};printf("%d %d %d %d\n",isalpha(values[0])!=0,isalpha(values[1])!=0,isalpha(values[2])!=0,isalpha(values[3])!=0);return 0;}
Result
1 1 0 0
The example tests `A`, `z`, `7`, and `-` in the initial `C` locale and normalizes each result with `!= 0`. Output `1 1 0 0` shows that both letters pass, whereas the digit and hyphen do not.