CKTIS / C
<ctype.h> — character classification and conversion
The <ctype.h> header provides character-category tests and case conversion with a restricted argument domain.
Version: C23; repository compiler flag, production runtime not attested
Syntax
#include <ctype.h><ctype.h> declares functions including isalpha, isdigit, isspace, tolower, and toupper. Tests return zero or a nonzero value, not necessarily 1. Conversions return int; without a corresponding mapping, they leave the argument unchanged. Results can depend on locale.
The int argument must equal EOF or be representable as unsigned char; otherwise, behavior is undefined. For a char value c, the cast (unsigned char)c is sufficient if UCHAR_MAX <= INT_MAX (both constants are defined in <limits.h>). Otherwise, check that (unsigned char)c <= INT_MAX before calling the function, and pass the cast result only if that check succeeds. Converting an out-of-range value to int can yield a negative argument other than EOF, which causes undefined behavior. Keep the result of getchar as int and check for EOF before casting.
Examples
#include <ctype.h>
#include <stdio.h>
int main(void)
{
char c = 'a';
printf("%d %c\n", isalpha((unsigned char)c) != 0,
toupper((unsigned char)c));
return 0;
}
Result
1 A
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.