Forum was down at end of lunch, then I had meetings and other business.
I never really went in for iostreams, so I had to write a sample program to test it out. To create the text file, I copied the first 15 rows of data from your Excel file to a text file:
Code:
#include <fstream.h>
int main(void)
{
double f1, f2, f3, f4;
ifstream inf;
inf.open("xdata.txt");
// read in the first four values, then echo them out
inf >> f1 >> f2 >> f3 >> f4;
cout << f1 << " " << f2 << " " << f3 << " " << f4 << endl;
// read in the next four values, then echo them out
inf >> f1 >> f2 >> f3 >> f4;
cout << f1 << " " << f2 << " " << f3 << " " << f4 << endl;
inf.close();
return 0;
}
C:\dcw\PROJECTS>head xdata.txt
0.03 44.00 47.29 8.71
0.01 44.06 47.38 8.57
0.04 44.07 47.15 8.78
0.01 43.92 47.45 8.64
0.00 44.20 47.21 8.59
0.06 44.01 47.22 8.77
0.00 44.11 47.29 8.60
0.03 44.34 47.15 8.51
0.00 44.30 47.06 8.64
0.03 44.59 46.84 8.56
Program Output:
0.03 44 47.29 8.71
0.01 44.06 47.38 8.57
So then, yes, ifstream treats spaces as delimiters between values. Plus, I believe that it automatically goes to the next line when it needs to. So then really, I'm just having it read four values at a time and it will do so no matter how the lines are set up. Though you should keep it four to a line so that the data file will be more human-readable.
You mentioned that the filename is in an AnsiString. If ifstream::open doesn't like that, you should be able to use the c_str method to provide it a char* :
Code:
AnsiString fname;
inf.open(fname.c_str);
As to your question, "do numbers also have the '/0' end character?":
First, you mean '\0', the null terminator.
Second, the null terminator only applies to string variables. The numbers in your data file are actually strings.
Third, ifstream::>> performs the conversion from string to numeric (double in my test), so you don't have to worry about it.
BTW, when in doubt about something, write a short test program.