Method 1: #include char * fun (char * s)
{INT LEN = 0, I; char Temp; for (i = 0; * (S I)! = '/ 0'; i ); len = i; for (i = 0; i Using Namespace STD Char * Fun (char * s)
{INT LEN = Strlen (s); INT i = 0; char * TEMP; TEMP = New char [len]; // is a TEMP allocation space. That is, initialization. While (len> 0) // change to LEN> 0, otherwise this cycle will not be executed once! {TEMP [i] = s [len-1]; // Change to LEN-1, this is the last element of S! I ; len-;} TEMP [i] = '/ 0'; cout << Temp << endl; return temp;}
Void main () {char * str = "WHO Are you!"; str = fun (str); cout << str << endl;}