So I need to read a file into these vectors. The file goes like this:
Basename Number of locations X1 Y1 X2 Y2 ...X2104 Y2104
kdkdsk 2104 32.012 50.393 59.302 58.392
So it needs to read the basename, number of locations, and then based on the number of locations, read each of those into a vector and eventually do some calculations based on that.
Right now it is only reading the first one. And I can't use istream.
Lines 30-40: it will read everything it can into coords vectors (until it fails), then increases count. All subsequent loops will skip reading (as stream is in failed state) increases count. More: when count becomes equal to numberoflocation, line 24 condition fails because stream is still in failed state.
HowToFix:
1) Get rid of inner loop and rewrite middle one condition as follows: while ((count < numberoflocations) && (myReadFile >> x >> y))
2) Do not forget forget to check stream state after and deal with it accordingly (fail after middle loop is probably should result in program termination, when fail and eof after outer loop is fine)