Roedy Green said:
for you C programmers:
-traverse the array of character (char*)
-while the character you are currently at is not a space, add it to a
temporary character array. This means that you have each word in its
own "special spot" and you can then traverse these with ease.
-store each temporary char array in another array and then traverse it
from the end, printing out each value as is. Don't forget to add
spaces back into this... since we did not store spaces in the first
place.
for you JAVA programmers:
-take in the string.
-tokenize it with Java.util.StringTokenizer
-store each value in an array of strings (String[])
-traverse the array and print each element starting from the back.
With spaces, as the StringTokenizer does not store spaces.
I agree with the posts above... this does sound like a homework
question. Since I am a university student aswell, I went through this
too... It takes a bit until you can start visualizing the algorithms
and solutions to the programs. These String manipulation algorithms
are the meat and butter of learing to program.
Cheers.