COHERENT manpages

This page displays the COHERENT manpage for tolower() [Convert characters to lower case].

List of available manpages
Index


tolower() -- ctype Function (libc)

Convert characters to lower case
#include <ctype.h>
int tolower(c) int c;

The function tolower() converts the  character c to lower case.  It returns
c converted  to lower case.  If  c is not upper-case  character, that is, a
character for which isupper() returns true, toupper() 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[100];

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

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

See Also

_tolower(),
libc,
toupper()
ANSI Standard, §7.3.2.1
POSIX Standard, §8.1