l bucle @ .eof () no funciona
Estoy tratando de leer los números de un archivo y ponerlos en una matriz. En este momento, cuando ejecuto el programa, imprime 8 números, luego la línea termina e imprime los mismos 8 números. Está en un bucle sin fin. ¿Qué estoy haciendo mal
#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;
}