2.2.2 to… Functions
Declarations:
int tolower(int
character);
character
int toupper(int);
The to… functions provide a means to convert a single character. If the character matches the appropriate condition, then it is converted. Otherwise the character is returned unchanged.
Conditions:
tolower | If the character is an uppercase character (A to Z), then it is converted to lowercase (a to z) |
toupper | If the character is a lowercase character (a to z), then it is converted to uppercase (A to Z) |
Example:
#include<ctype.h> #include<stdio.h> #include<string.h> int main(void) { int loop; char string[]="THIS IS A TEST"; for(loop=0;loop<strlen(string);loop++) string[loop]=tolower(string[loop]); printf("%s\n",string); return 0; }