Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

toupper — convert a lowercase letter to uppercase

toupper from <ctype.h> returns a corresponding uppercase letter according to the current locale, or leaves the value unchanged.

Version: C23; repository compiler flag, production runtime not attested

Syntax

#include <ctype.h>
int toupper(int c);

toupper takes and returns int. For a lowercase letter, it returns a corresponding uppercase letter according to the current locale; if several correspond, the choice is fixed for that locale. Otherwise, it returns the argument unchanged.

The argument must be representable as unsigned char or equal EOF; otherwise, behavior is undefined. For a char c variable, use toupper((unsigned char)c). Keep a getchar() result as int, preserving EOF without casting.

The function modifies neither its argument nor an entire string. It is not a byte-by-byte UTF-8 text converter.

Examples

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

int main(void)
{
    char c = 'a';
    printf("%c %c\n", toupper((unsigned char)c), toupper('7'));
    return 0;
}

Result

A 7

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources