This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: trouble using ifstream as a class member


Hello,

I am dealing with the same problem (libstdc++ 3.3 from SuSE 8.2).

The problem is that if one has a variable of type ifstream within a class, then the status-bits are not set to 0, if one even closes the file and then opens it again, i.e. if one has read the file until the eof-status-bit was set, then it does not help to write
tis.close();
tis.open(filename);
because the eof-bit is still set although tis.tellg() gives that it is at the beginning (in my code, I first tried with tis.seekg(0) to come to the beginning and then I saw that even closing and opening does not help at all)!


What might help (I have found this solution yesterday evening, but not tested totally) is:
tis.close();
tis.open(filename);
tis.clear();


So, at least to write somewhere the command tis.clear() which sets all status-bits to 0 explicitely, but one must be careful not to use it too often!


This problem also occurs on IBM-machines, but not on a SUN!



Hope this helps, Gerald


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]