1: // Created by Frank M. Carrano and Timothy M. Henry. 2: // Copyright (c) 2017 Pearson Education, Hoboken, New Jersey. 4: /** Writes a character string backward. 5: @pre The string s to write backward. 6: @post None. 7: @param s The string to write backward. */ 8: void writeBackward(std::string s) 9: { 10: int length = s.size(); // Length of string 11: if (length > 0) 12: { 13: // Write the last character 14: std::cout << s.substr(length - 1, 1); 15: 16: // Write the rest of the string backward 17: writeBackward(s.substr(0, length - 1)); // Point A 18: } // end if 19: 20: // length == 0 is the base case - do nothing 21: } // end writeBackward