Cygwin not reading in consecutive files

Dear Root Talk,

I came across this curious problem when running the attached code on Cygwin:

it reads in the first .txt file properly, but then the second file is not read in properly.

If I change the starting point of the code to read in the “second” file first it reads it in properly.

The execution of the code is:

root [] .L spark_eff.cpp
root [] SparkEff(1)

This code does work on both a Sun machine and also OS X.

Any thoughts as to what is going on?

Thanks

EDIT: I am running ROOT 5.08 and Cygwin 1.5.19-4
spark_eff.cpp (2.42 KB)
2.txt (2.05 KB)
1.txt (2.28 KB)

Hi,

Some time ago I came across the same problem (not with cygwin but with SuSE 10). I don’t have an explanation for it but maybe a solution. Just shift your declaration of the ifstream into the loop. So instead of doing

ifstream in; for (...) { in.open(filename); in.close(); }
do

for (...) { ifstream in(filename); in.close(); }
That did the trick for me.

Cheers, Mathias

Thank you for the prompt reply.

Placing ifstream creation inside of the for loop did indeed help!