I can't get the .eof() function to work. It seems that it will not break the loop. It tries to read after end of file and crashes due to arbitrary values.
File operations are typically abstracted away into a function. For example:
1 2 3 4 5 6 7 8 9 10 11 12
struct point
{
int x, y;
point( int x = 0, int y = 0 ): x( x ), y( y ) { }
};
istream& operator >> ( istream& ins, point& pt )
{
ins >> pt.x;
ins >> pt.y;
return ins;
}
1 2 3
point INPUT1;
vector <point> plot;
while (dataFile >> INPUT1) plot.push_back( INPUT1 );