

tolower()                  ctype Macro                  tolower()




Convert characters to lower case

#iinncclluuddee <ccttyyppee.hh>
iinntt ttoolloowweerr(_c) iinntt _c;

tolower converts  the letter c to lower  case.  tolower returns c
converted to  lower case.   If c  is not a  letter or  is already
lower case, then tolower returns it unchanged.

***** Example *****

The  following  example  demonstrates  tolower and  toupper.   It
reverses the case of every character in a text file.


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



main()
{
        FILE *fp;
        int ch;
        int filename[20];



        printf("Enter name of file to use: ");
        fflush(stdout);
        gets(filename);



        if ((fp = fopen(filename,"r")) != NULL) {
                while ((ch = fgetc(fp)) != EOF)
                        putchar(isupper(ch) ? tolower(ch) : toupper(ch));
        } else
                 printf("Cannot open %s.\n", filename);
}


***** See Also *****

ctype, toupper()











COHERENT Lexicon                                           Page 1


