// Pay attention to some of the remarks. # Include
# Include
// 1 --- the difference between cstring and string: int main () {using namespace std; cout <"Please Enter a string: \ n"; string word; cin> word; // char temp; // 3 --- int I, j; // for (I = 0, j = word. size ()-1; I <= j; ++ I, -- j) for (I = 0, j = word. length ()-1; I <= j; ++ I, -- j) // 2 --- word. size () word should be an array. word. length () and word. size () indicates the length of the array. because the array subscript starts from 0. therefore,-1 is required to prevent the subscript from crossing the border {char temp; // The internal declaration temp is allocated and released in each loop, which is slower than the declaration before the for loop body, when the cycle ends, the/char temp = word [I]; // 3 --- // char temp = word [I]; // 3 --- temp = word [I]; word [I] = word [j]; word [j] = temp;} cout <