Chapter Contents

Previous

Next
tolower

tolower



Translate Uppercase Character to Lowercase

Portability: ISO/ANSI C conforming, UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
IMPLEMENTATION
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <ctype.h>

int tolower(int c);


DESCRIPTION

tolower translates an uppercase character to the corresponding lowercase character. The argument must either be a char value or EOF . The mapping of uppercase to lowercase characters is locale dependent.


RETURN VALUE

If the argument is an uppercase character, the corresponding lowercase character is returned; otherwise, the argument value is returned.


IMPLEMENTATION

tolower is implemented by the compiler as a built-in function, unless you use the name tolower with #undef .


EXAMPLE

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

#define MAX 40

main()
{
   char *str, *ptr;
   char input[MAX];

   puts("Enter a string of uppercase characters (maximum of 40):");
   str = gets(input);
   ptr = str;

      /* Translate all uppercase characters in a string to      */
      /*  lowercase characters.                                 */
   while (*str) {
      *str = tolower(*str);

         /* Increment outside of macro for maximum portability. */
      str++;
   }
   printf("%s\n", ptr);
}


RELATED FUNCTIONS

islower , memlwr , strlwr , toupper


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.