6.3.13 tolower Function

Convert a character to a lowercase alphabetical character.

Include

<ctype.h>

Prototype

int tolower (int c);

Argument

c
The character to convert to lowercase.

Return Value

Returns the corresponding lowercase alphabetical character if the argument, c, was originally uppercase; otherwise, returns the original character.

Remarks

Only uppercase alphabetical characters may be converted to lowercase.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

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

int main(void)
{
  int ch;

  ch = 'B';
  printf("B changes to lowercase %c\n",
          tolower(ch));

  ch = 'b';
  printf("b remains lowercase %c\n",
          tolower(ch));

  ch = '@';
  printf("@ has no lowercase, ");
  printf("so %c is returned\n", tolower(ch));
}

Example Output

B changes to lowercase b
b remains lowercase b
@ has no lowercase, so @ is returned