|
|
1.1 ! root 1: ! 2: ! 3: tolower() ctype Macro tolower() ! 4: ! 5: ! 6: ! 7: ! 8: Convert characters to lower case ! 9: ! 10: #iinncclluuddee <ccttyyppee.hh> ! 11: iinntt ttoolloowweerr(_c) iinntt _c; ! 12: ! 13: tolower converts the letter c to lower case. tolower returns c ! 14: converted to lower case. If c is not a letter or is already ! 15: lower case, then tolower returns it unchanged. ! 16: ! 17: ***** Example ***** ! 18: ! 19: The following example demonstrates tolower and toupper. It ! 20: reverses the case of every character in a text file. ! 21: ! 22: ! 23: #include <ctype.h> ! 24: #include <stdio.h> ! 25: ! 26: ! 27: ! 28: main() ! 29: { ! 30: FILE *fp; ! 31: int ch; ! 32: int filename[20]; ! 33: ! 34: ! 35: ! 36: printf("Enter name of file to use: "); ! 37: fflush(stdout); ! 38: gets(filename); ! 39: ! 40: ! 41: ! 42: if ((fp = fopen(filename,"r")) != NULL) { ! 43: while ((ch = fgetc(fp)) != EOF) ! 44: putchar(isupper(ch) ? tolower(ch) : toupper(ch)); ! 45: } else ! 46: printf("Cannot open %s.\n", filename); ! 47: } ! 48: ! 49: ! 50: ***** See Also ***** ! 51: ! 52: ctype, toupper() ! 53: ! 54: ! 55: ! 56: ! 57: ! 58: ! 59: ! 60: ! 61: ! 62: ! 63: ! 64: COHERENT Lexicon Page 1 ! 65: ! 66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.