| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
confused how to do this program
i am confused as to how to do this problem. i am takin a cpsc 140 class and i need to finish this assignment to graduate...please someone help me!! i just need help getting started
Write a C++ program that reads in an unknown number of characters from the a text file, count the number of words, and print each word in reverse to the screen. Words are delimited by blanks, tabs, newlines and the end of file. Note that mulitple whitespace characters should only count one word. Hint: You can use the get method to enter whitespace |
|
#2
|
|||
|
|||
|
There is similar postings in this forum. One way you can do it is to open the file using an istream object, and read it into a string . Use the member functions of the string class to format text. Here is a link to the string class description http://www.msoe.edu/eecs/ce/courseinfo/stl/string.htm
Use the find method to look for whitespace, and use the reverse algorithm found in the <algorithm> library to reverse the words. I will leave the finer details to you. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > confused how to do this program |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|