// StringTran.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include<iostream> #include<string> using namespace std; char* tran(char str[]) { int i=0; while(str[i]!='/0') { if(str[i]>='a'&&str[i]<='z') { int c=str[i]; str[i]=c-('a'-'A'); i++; } else i++; } return str; } char* reverse(char str[]) { int n=strlen(str); char temp; for(int i=0;i<=n/2;i++) { //首尾调换 temp=str[i]; str[i]=str[n-1-i]; str[n-1-i]=temp; } return str; } int _tmain(int argc, _TCHAR* argv[]) { char s[]="###The girl is very beautiful!!!@@@"; cout<<s<<endl; //把字符串转化为大写 char *p=tran(s); cout<<p<<endl; //把字符串翻转 char t[]="01234567890"; cout<<t<<endl; char *pt=reverse(t); cout<<pt<<endl; getchar(); return 0; }