[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] C++ programming: keeping count of data items read from file



Michael Marsh wrote:
On Tue, May 6, 2008 at 1:50 PM, H.S. <hs.samix@gmail.com> wrote:
 As I mentioned earlier, the issue is how do I count items read in one line,
or before the next EOL? Counting total items is not a problem.

 Perhaps a different way to say this is, how do I detect if I have reached
an EOL while reading doubles from a file stream.

Can you read full lines out into, eg, a stringstream, and parse your
doubles out of that?  You'd hit an EOF at the end of each line in that
case.  I'm not sure how you'd get stream out line-at-a-time, though
there may be a stream operator that sets the appropriate behavior.

Yup, that could be done by getting a line till the end of "\n" character and then parsing the line. I was just wondering if there was any other way (was trying to avoid parsing).



Just a random idea off the top of my head.



Reply to: