Design a program called reverser.cpp which should accept a string from the user and then return the string in reverse order. It might be interesting to enhance this a bit by reversing the string, converting it all to upper case and keeping only the alphabetic characters. In order to get at the individual pieces of a string, you will need to understand a little bit about arrays and loops. A string is actually an array of single characters. For example:
string abe = "Lincoln";abe is actually an array. abe is 'L', abe is 'i', ... and abe is 'n'. There is also a function or method for a string which tells its length and that would be abe.length() which is 7 in this case.
string auto = "Cadillac"; cout << auto.length() << endl; // this should print 8 cout << auto << endl; // this should print out 'd' (remember we start at zero)
Advance to Step Nine
Return to the Table of Contents