I have noticed a strange behaviour when running a simple macro that reads a text file with lines of numbers. I just want to read these numbers. The code is below.
{
#include <fstream>
#include <sstream>
{
using namespace std;
ifstream f1("list.txt",ios_base::in);
string line;
istringstream iss;
int i = 0;
float a;
while(getline(f1,line)){
iss.str(line);
cout << line << endl;
while(iss >> a){
cout << i << " " << a << endl;
i++;
}
iss.clear();
cout<< "end loop " << a << endl;
}
f1.close();
}
}
please don’t use unnamed macros, especially when they #include files. Just give the function you define in the file the same name as the filename (macro() for macro.C) and you can execute it as before.
This is fixed by revision 32859 on the root trunk. The problem was that cint was including the state of the eof bit in the if test when the standard says it should use !fail(), which checks only the fail bit and the bad bit, not the eof bit.