![]() |
| ||
| confused how to begin this program i am taking a cpsc 140 class and i'm a little confused how to begin my assignment. 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 . i dont recall what the get method is. if anyone can start me out i would be greatly appreciated. thanks :) |
| ||
| Re: confused how to begin this program Quote:
|
| ||
| Re: confused how to begin this program could you help me get started on this program. i dont want u write the program for me, i just would like to know what steps i have to take to figure it out on my own |
| ||
| Re: confused how to begin this program #include <iostream> |
| ||
| Re: confused how to begin this program Just a little help ... [php]// pulls the words out of a text stream string get_word(istream& in) { char ch; string s; while(in.get(ch)) { // these characters separate the words if (ch == ' ' || ch == ',' || ch == '.' || ch == '\n' || ch == '\t') break; s.push_back(ch); // build the word } return s; } [/php] |
| ||
| Re: confused how to begin this program steps: 1) order a large amount of coffee 2) order some pizzas 3) kickstart your brain 4) start thinking how you would solve it 5) write down your solution in words on a piece of paper 6) translate that into a flowchart and/or other diagrams 7) translate that into a functional model of your application 8) translate that into code 9) test and fix until working |
| ||
| Re: confused how to begin this program thanks for all the help..the only thing i cant figure out now is how to put the actual text file in. the text is : this is a file containing lots of words with whitespace such as tabs and endoflines and blanks but no punctuation you should be counting the words and reversing each word before echoing this tothescreen at the end print the number of words in the file is there a way for me to put this in without actually putting all this text in my code? |
| ||
| Re: confused how to begin this program Sure, and that's exactly how you should do it: Create a textfile on disk. Read in the file in your program. C(++) has full facilities for reading and writing any kind of file built right into the core language. |
| ||
| Re: confused how to begin this program Quote:
|
| All times are GMT -4. The time now is 4:42 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC