Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

isupper — C23 character classification function

`isupper(c)` from `<ctype.h>` returns a nonzero value when `c` is an uppercase letter in the current locale; in the `C` locale this covers `A` through `Z`. The result is merely logically nonzero, not necessarily exactly `1`.

Version: C23

Syntax

int isupper(int c);

isupper(c) from <ctype.h> returns a nonzero value when c is an uppercase letter in the current locale; in the C locale this covers A through Z. The result is merely logically nonzero, not necessarily exactly 1.

The example tests A, Z, a, and 7, normalizing every result with != 0. Output 1 1 0 0 demonstrates both ends of the basic range and rejects the lowercase letter and digit.

The argument must be EOF or a value representable as unsigned char; passing a negative plain char has undefined behavior. For a byte use isupper((unsigned char)ch), but do not cast EOF. Byte classification under LC_CTYPE is not a complete Unicode-uppercase test; use tolower for conversion.

Examples

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

int main(void) {
    int values[] = {'A', 'Z', 'a', '7'};
    printf("%d %d %d %d\n", isupper(values[0]) != 0, isupper(values[1]) != 0, isupper(values[2]) != 0, isupper(values[3]) != 0);
    return 0;
}

Result

1 1 0 0

The example tests `A`, `Z`, `a`, and `7`, normalizing every result with `!= 0`. Output `1 1 0 0` demonstrates both ends of the basic range and rejects the lowercase letter and digit.

Sources