Hello,
how to read all numbers from a file to std::vector?
I have tried this one:
but if there (in the file) is not end of file right after the last number, then the while loop will pass one more time and put one "extra" number to my vector -> which is bad.Code:ifstream in; vector numbers; . . . int number; while (in.good()) { in >> number; numbers.push_back(number); }
Does anybody know a solution to this problem?