Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

tolower — convert to lowercase

tolower from <ctype.h> maps an uppercase letter to lowercase using the locale. Its argument must fit unsigned char or equal EOF.

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

Syntax

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

tolower returns an int: the lowercase counterpart of an uppercase letter under the current locale, or the unchanged argument if no such mapping exists. It does not modify the input variable; assign the result.

The argument must be representable as unsigned char or equal EOF; otherwise behavior is undefined. For a char value, use tolower((unsigned char)c). Keep a getchar() result as int to preserve EOF until checked. This is not whole-text Unicode conversion.

Examples

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

int main(void)
{
    char text[] = "AbC 123!";
    for (int i = 0; text[i] != '\0'; ++i) {
        text[i] = (char)tolower((unsigned char)text[i]);
    }
    puts(text);
    return 0;
}

Result

abc 123!

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