C Standard Library

C <ctype.h> - tolower() Function



The C <ctype.h> tolower() function is used to convert the given character to lowercase according to the character conversion rules defined by the currently installed C locale.

In the default "C" locale, the following uppercase letters ABCDEFGHIJKLMNOPQRSTUVWXYZ are replaced with respective lowercase letters abcdefghijklmnopqrstuvwxyz.

Syntax

int tolower ( int ch );               

Parameters

ch Specify the character to be converted, casted to an int, or EOF.

Return Value

Returns lowercase version of ch or unchanged ch if no lowercase value is listed in the current C locale.

Example:

The example below shows the usage of tolower() function.

#include <stdio.h>
#include <ctype.h>
 
int main (){
  char str[50] = "HELLO World!";

  //converting str into lower case
  int i = 0;
  while(str[i]) {
    str[i] = tolower(str[i]);
    i++;
  }

  //displaying the output
  printf("%s\n", str);  
  return 0;
}

The output of the above code will be:

hello world!

❮ C <ctype.h> Library