tolower() – toupper() — Convert Character Case

Format

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

Language Level: ANSI

Threadsafe: Yes.

Locale Sensitive: The behavior of these functions might be affected by the LC_CTYPE category of the current locale. For more information, see Understanding CCSIDs and Locales.

Description

The tolower() function converts the uppercase letter C to the corresponding lowercase letter.

The toupper() function converts the lowercase letter c to the corresponding uppercase letter.

Return Value

Both functions return the converted character. If the character c does not have a corresponding lowercase or uppercase character, the functions return c unchanged.

Example that uses toupper() and tolower()

This example uses the toupper() and tolower() functions to change characters between code 0 and code 7f.

#include <stdio.h>
#include <ctype.h>
 
int main(void)
{
   int ch;
 
   for (ch = 0; ch <= 0x7f; ch++)
   {
      printf("toupper=%#04x\n", toupper(ch));
      printf("tolower=%#04x\n", tolower(ch));
      putchar('\n');
      }
}

Related Information



[ Top of Page | Previous Page | Next Page | Contents | Index ]