/* ----------------Mahin Hackler-------------------Feb.4, 1996------------- Lab 3 Write a program that 1.reads in a string of arbitrary length (less than 20 characters), 2.write out the string, 3.reverses the string and prints the resultant string Be sure to include prompts for the user and a descriptive heading for the output. */ #includevoid main() { char *charstring; charstring = new char[20]; char *reversecharstring; reversecharstring = new char[20]; cout << "This program will ask you to enter a string of characters.\n"; cout << "The string must be less then 20 characters. The characters\n"; cout << "will be displayed for you and then they will be displayed\n"; cout << "in reverse.\n"; cout << "Please enter a string of characters that is 20\n"; cout << "less then 20 characters.\n"; //reads in a string of characters cin >> charstring; cout << "Here is the string of characters you entered\n"; cout << charstring << "\n"; //writes out the string int i = 0; while(charstring[i] != '\0') { i++; } int size = i; for(int j = 0; j < size; j++) { reversecharstring[size - j - 1] = charstring[j]; } reversecharstring[size] = '\0'; cout << "Here are the characters in reverse\n"; cout << reversecharstring; }