#include<iostream> #include<algorithm> #include<string> #include<string.h> using namespace std; void ToUpper(char *str) { char *beg=str; char ch; for(int i=0,length=strlen(str);i<length;i++,beg++) { ch=*beg; if(ch>='a'&&ch<='z') *beg=ch&0xDF; } } void ToLower(char *str) { char *beg=str; char ch; for(int i=0,length=strlen(str);i<length;i++,beg++) { ch=*beg; if(ch>='A'&&ch<='Z') *beg=ch|0x20; } } int main() { char hello1[]="I Hate This Fucking World!NOthing i WOuld care about&*^%"; char hello2[]="I Hate This Fucking World!NOthing i WOuld care about&*^%"; ToUpper(hello1); ToLower(hello2); cout<<"the string after use ToUpper------"<<hello1<<endl; cout<<"the string after use ToLower------"<<hello2<<endl; return 0; }