We are learning how to use the lenght, s[], and substr methods....Anybody have any idea how to finish up the if statement so that when I enter a string backwards it reverses it? Try to keep it as basic as possible i'm really new to this. THANKS ALOT!
So would: "Hello world my name is Bob" become: "Bob is name my world Hello"
or "boB si eman ym dlrow olleH"
if it's the first then perhaps you can use find_last_of " " and just print out the substrings between each space.
if the later then:
can you use the c_str() method in string class? because that will give you a char*( char[] for simplicity sake ) which you can just iterate backwards after finding the length of the std::string.
ahhh ok, well if that's the way your supposed to do it I guess it works in this fashion:
we have a string: "abcdef" lets say, use substring to return the last letter by using (length()-1,length());
store this in a reverse variable and store the first part minus the last char in your original string(0,length()-1);, then do the same again, but each time concatenating the reverse string.
So first iteration you would get an 'f'
second an 'e'; and appened it to the string: f + e
then a 'd': f + e + d
... and so on..