| Printable Version of Topic
Click here to view this topic in its original format |
| IceTeks Forums > Programming > c++ (sstream).. |
| Posted by: jakskal Oct 26 2006, 04:03 PM | ||||
| ok..i'm working on the following problem: Write a program that reads up to 10 numbers per line to be stored in an array. The program calculates and displays the sum of the numbers, the mean (arithmetic average) of the numbers, and the largest and smallest values entered for each line. Here's the file it reads from:
i've got every except the part where it skips the line when it reaches the end of line..i know it has something to do with the sstream function. any help?
|
| Posted by: jakskal Oct 26 2006, 08:04 PM |
| nevermind..got it.. |
| Posted by: Red Squirrel Oct 26 2006, 08:43 PM |
| Good to hear, since I've never used sstream class before or dont recall, so could not see what was wrong. |
| Posted by: jakskal Oct 26 2006, 10:50 PM | ||||
i didn't use sstream...i ended up using something simple!
it basically checks the file for the end of line and jumps onto the next line.. how'd i miss it?! |
| Posted by: Red Squirrel Oct 27 2006, 03:19 AM |
| Yeah thats how I'd normally do it. Keep in mind that some files also use \r\n (*nix? , or is it windows? I always get confused) for return sequence. But searching for \n should do the trick in most cases. But if you start seeing weird chars its probably the \r |
| Posted by: jakskal Oct 29 2006, 06:52 PM |
| hey...i need to check for a blank line which contains nothing and skip it..kinda similar to above..but the above code doesn't do the trick this time...anyone? |
| Posted by: jakskal Oct 29 2006, 08:38 PM |
| nvm..got it! |