Vart I am not looking for an error, but for the EOF.
Cyberfish, with this code
Code:
while(infile) // Will read the last line twice
{
if(!N) //Read first line of file
{
infile >> d;
P.setD(d);
infile >> N;
infile >> epsilon;
infile >> t;
}
else
{
double hCoords[P.getD()];
for(size_t i = 0 ; i < P.getD() ; ++i)
{
infile >> d;
//std::cout << d << " " << i << std::endl;
//if(d==EOF)break;
hCoords[i] = d;
std::cout <<hCoords[i] << "\n";
}
//Read min distance of origin
infile >> d;
std::cout << hCoords[0] << " " << hCoords[1] << " "
<< hCoords[2] << " " << d << "\n";
}
}
I read as expected and I read the line twice, which is
Code:
-0
-0
-1
-0 -0 -1 -0
0
-1
0
0 -1 0 0
-1
-0
-0
-1 -0 -0 -0
0.57735
0.57735
0.57735
0.57735 0.57735 0.57735 0.57735
0.57735
0.57735
0.57735
0.57735 0.57735 0.57735 0.57735
Here is my file.
Code:
3 4 0.1 3
-0.000000000 -0.000000000 -1.000000000 -0.000000000
0.000000000 -1.000000000 0.000000000 0.000000000
-1.000000000 -0.000000000 -0.000000000 -0.000000000
0.577350269 0.577350269 0.577350269 0.577350269
If I uncomment the two lines of code, I am getting this
Code:
-0
-0
-0 -0 -1.71101e-41 -0
0
0 -0 -1.71101e-41 0
0
0 -0 -1.71101e-41 -0
-0
-0
0.57735
-0 -0 0.57735 0.57735
0.57735
0.57735
0.57735
0.57735 0.57735 0.57735 0.57735
Moreover, I tried infile.eof(), but with no use at all.