Hey guys I am new at c++ I was just wondering if someone could show me how to print a string in reverse order(for example: "today is Wednesday " to "Wednesday is today"). My professor said we should begin with a null string and build it one word at a time. i have been working on this for weeks, and cannot figure it out. If someone can help me out,I would greatly appreciate it!!!
using namespace std;
It's kind of funky, because it adds each word with the letters in reverse order, but in the right word order, to the nullstring. Then, before we print, we reverse the elements of the nullstring, effectively re-reversing the order of the characters, but this time reversing the order of the words.
It also doesn't handle punctuation, and it only works if the sentence string ends with a space. I didn't think this was too much of a problem, because in your original example, the original string also ends with a space. However, this introduces an extrenuous space at the beginning of the nullstring.
Also, it doesn't handle capitalized letters in any way. All that stuff is for you to figure out.