Author | Message |
---|---|
lakerfan94
Posts: 143
|
Posted 22:29 Jan 09, 2016 |
For homework 1 and looking specifically at the input file we have to read from, what's the format it has to be in? Is it just one word per line or per each line, there are going to be multiple words separated by whitespaces? The reason I ask is that an input stream only reads up to the first whitespace. So how are we going to parse the line into multiple words and then try to process each word individually? I've already figured out how to calculate the sum of the letters for a given word but I can't make much more progress because of my concern of the whitespaces between words in sentences. That is, if the format of the input file involves multiple words per line, each word separated by a whitespace. |
vluu2
Posts: 64
|
Posted 22:31 Jan 09, 2016 |
Homework 1 Cervantes Class...? I wonder how I'm getting this when Cervantes doesn't teach CS 332C o.O |
lakerfan94
Posts: 143
|
Posted 22:33 Jan 09, 2016 |
Cervantes is teaching CS332C |
vluu2
Posts: 64
|
Posted 22:34 Jan 09, 2016 |
Oh.................... #MYBAD |
comlor
Posts: 16
|
Posted 22:41 Jan 09, 2016 |
if you read an entire line with multiple words separated by white space or any other character the result is stored in a string. That string can be parsed into individual words using the known separator. Every character has an ASCII value. I am attaching a ASCII character table you can use for a reference I would suggest you read these getline - http://www.cplusplus.com/reference/string/string/getline/ string - http://www.cplusplus.com/reference/string/string/ - look at find_first_of and substr functions I am also curious as to the structure of the text file. Do we calculate the entire line or substring each word out of a line and only calculate the individual words. Last edited by comlor at
22:52 Jan 09, 2016.
|