Is there a function in c++, like in pascal, so you can detect the end of a line? I know in pascal it would be like infile.eoln(), but that doesn't work in c++.
If you're trying to read from a file, use some function that will read from a file. Sitting at the beginning of a file and waiting for the end to come will not do much.
^yeah but what if the line can't be treated as a string?
On the line, I am wanting to get, there is going to be 1 to 5 double's. Since I don't know how many doubles are going to be on that line, I just need to grab the whole line.
Then I was going to fill an array with how ever many double's were on that line:
double arr[5];
int i;
for (i=0; not end of the line; ++i)
{infile>>arr[i];
}
Is there a function in c++, like in pascal, so you can detect the end of a line? I know in pascal it would be like infile.eoln(), but that doesn't work in c++.
By the way, since we're posting at similar times, I thought I'd bring this up FWIW:
So all istringstream does is make each number on that one line ready to be stored into a variable?
It is used to do things like >> from a string instead of cin or an ifstream.
So the code I posted reads the whole line into a string, rather than going one value at a time (because both a newline and a space are whitespace characters, it might be tougher to distinguish using other means). Then it parses each double via the stringstream and >> operator.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.