I'm trying to read in numbers from a file and putting them into an array. Right now when I run the program it prints 8 numbers, then the line ends and prints the same 8 numbers. It's in a never ending loop. What am I doing wrong?
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int num;
ifstream infile;
infile.open("euler8Nums.txt");
infile >> num;//must attempt to read info prior to an eof() test
while(!infile.eof()){
cout << num << endl;
infile >> num;
}
infile.close();
return 0;
}