.TH tolower() "" "" "ctype Function (libc)"
.PC "Convert characters to lower case"
\fB#include <ctype.h>\fR
\fBint tolower(\fIc\^\fB) int \fIc\^\fB;\fR
.PP
The function
.B tolower()
converts the character
.I c
to lower case.
It returns
.I c
converted to lower case.
If
.I c
is not upper-case character, that is, a character for which \fBisupper()\fR
returns true,
.B toupper()
returns it unchanged.
.SH Example
The following example demonstrates
.B tolower()
and
.BR toupper() .
It reverses the case of every character in a text
file.
.DM
#include <ctype.h>
#include <stdio.h>
.DE
.DM
main()
{
	FILE *fp;
	int ch;
	int filename[100];
.DE
.DM
	printf("Enter name of file to use: ");
	fflush(stdout);
	gets(filename);
.DE
.DM
	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.\en", filename);
}
.DE
.SH "See Also"
.Xr "_tolower()," _5Ftolowe
.Xr "libc," libc
.Xr "toupper()" toupper
.br
\*(AS, \(sc7.3.2.1
.br
\*(PX Standard, \(sc8.1
