/* testchar2.cpp CIS 150 David Klick 6/30/05 Making simple upper/lower case functions. */ #include #include using std::cout; void makeLowerCase(char* str); void makeUpperCase(char* str); int main(void) { char sample[] = "This is Dave's test string!"; cout << sample << '\n'; makeLowerCase(sample); cout << sample << '\n'; makeUpperCase(sample); cout << sample << '\n'; return 0; } // This function converts a string to lowercase. // Warning: It modifies the input string. void makeLowerCase(char* str) { while (*str != '\0') { *str = tolower(*str); str++; } } // This function converts a string to uppercase. // Warning: It modifies the input string. void makeUpperCase(char* str) { while (*str != '\0') { *str = toupper(*str); str++; } } /* Sample output: This is Dave's test string! this is dave's test string! THIS IS DAVE'S TEST STRING! */