Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

tolower - Convert uppercase letters to lowercase

&pagelevel(4)&pagelevel

Definition   

#include <ctype.h>

int tolower(int c);

tolower converts the uppercase letter c (from the EBCDIC character set) to the corresponding lowercase letter. 

Return val.

The lowercase letter corresponding to c



if c is an uppercase letter.


c unchanged

if c is not an uppercase letter.                                                 

Note

tolower is implemented both as a macro and as a function (see section “Functions and macros”).

Example

The following program reads a string and converts the characters first to lowercase letters and then to uppercase letters. Characters that are neither uppercase nor lowercase letters (digits, special characters, etc.) remain unchanged.

#include <ctype.h>
#include <stdio.h>
int main(void)
{
  int i;
  char s[81];
  printf("Please enter a string (max. 80 characters)\n");
  scanf("%s", s);
  printf("And now everything in lowercase letters \n");
  for (i=0; s[i] != '\0'; ++i)
       if (isupper(s[i]))
           printf("%c", tolower(s[i]));
       else printf("%c", s[i]);
  printf("\n And in uppercase letters \n");
  for (i=0; s[i] != '\0'; ++i)
       if (islower(s[i]))
           printf("%c", toupper(s[i]));
       else printf("%c", s[i]);
  printf("\n");
  return 0;
}

See also

strlower, strupper, toupper, toascii, toebcdic, towlower