C examples for String:String Function
Create your own version of tolower() and toupper()
#include <stdio.h> #include <ctype.h> #include <string.h> //function prototypes void convertL(char *); void convertU(char *); int main()/*w ww. ja v a2 s . c o m*/ { char name1[] = " from "; char name2[] = " book2s.com "; convertL(name1); convertU(name2); } void convertL(char *str) { int x; for ( x = 0; x <= strlen(str); x++ ) str[x] = tolower(str[x]); printf("\nFirst name converted to lower case is %s\n", str); } void convertU(char *str) { int x; for ( x = 0; x <= strlen(str); x++ ) str[x] = toupper(str[x]); printf("Last name converted to upper case is %s\n", str); }