2013-09-23, 01:22 PM
The structs are used as a compact way of representing a paragraph/sentence. For example, the paragraph "Today is the 23rd of September. The current year is 2013" would be stored as:
line1: Today is the 23rd of September.
line2: The current year is 2013.
And today is word1 of sentence1, and so on and so on.
Since you're reading in a normal text file, the while loop should be while(!filename.eof()) so that you will continue reading inputs until there is nothing left in the file. Because sentences aren't stored as an array of words and paragraphs aren't stored as an array of sentences, you will have to use a switch statement to iterate through each individual element rather than have a while loop inside a while loop. Which then leads to how do you store the words and sentences. The only container data structure I can think of that works for this is a list, which will be incredibly tedious to iterate through and inserting elements in certain positions.
How I would think about this problem is that first start at a word and think about how you will parse the string. After that, think about how will you interpret the information once it's parsed correctly. Once you've done that, draw a 10x8 grid and think about "How do I insert this word at this certain position"?
line1: Today is the 23rd of September.
line2: The current year is 2013.
And today is word1 of sentence1, and so on and so on.
Since you're reading in a normal text file, the while loop should be while(!filename.eof()) so that you will continue reading inputs until there is nothing left in the file. Because sentences aren't stored as an array of words and paragraphs aren't stored as an array of sentences, you will have to use a switch statement to iterate through each individual element rather than have a while loop inside a while loop. Which then leads to how do you store the words and sentences. The only container data structure I can think of that works for this is a list, which will be incredibly tedious to iterate through and inserting elements in certain positions.
How I would think about this problem is that first start at a word and think about how you will parse the string. After that, think about how will you interpret the information once it's parsed correctly. Once you've done that, draw a 10x8 grid and think about "How do I insert this word at this certain position"?

