1. Please figure out how to use [code][/code] tags real soon.
Isn't the water mark at the back of the edit box, or the READ THIS FIRST links enough for you?
2. printf(arr[i]);
The first parameter of printf() is a control string, not your data.
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
>help me in aproper way
Say please, jerk. The least you could do is show some respect to the people who are volunteering their time to help you for nothing in return.
>i could print characters in reverse but not words
Okay, you can print the characters in reverse now try to physically reverse the string and print it as a whole. That solution will give you the words in reverse, but also the characters in each word reversed. So you need to make another pass and reverse each word. The string reverse solution can be generalized to handle both cases, but since this is typical homework, I can't give you code before you make an attempt.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>Is that the question is reversing each individual word ?
Yes, that's what the OP wanted.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
why son't you create an array of strings, and store in each string each word of your sentece, so you just have to print your array of strings backwards...
i'm sorry... but as narue, and our queen of daniweb, her majesty dani (in the anouncements posted in every forum) have already told you, WE DO NOT GIVE HOMEWORK TO THOSE THAT DO NOT SHOW ANY EFFORT
Nichito
Posting Virtuoso
1,602 posts since Mar 2007
Reputation Points: 424
Solved Threads: 57
Just an idea:
Two words are usually separated by " "(SPACE). So, you have a string, containing some words. Now you start from the end of the string, and put the character into a new string's 0th position. Test if the next character is space. If not shift the new string, put the char to the 0th position. If you find a space, print your new string, and reinitialize it.
Chaster
Junior Poster in Training
68 posts since Jun 2007
Reputation Points: 12
Solved Threads: 3
>Just an idea:
It sounds a great deal more complicated and less efficient than the usual double reverse trick.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401