This is the mail archive of the libstdc++@sourceware.cygnus.com 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]

Problem with ifstream


Hi,

I use gcc 2.95.2 + libstdc++ 2.90.8.
When I try to reuse an std::ifstream, I can't. Is it a) Normal  b) My
fault  c) A bug  d) Other  ?

Thanks in advance,
Regards

--
Benoît Sibaud
R&D Engineer France Telecom/BD/FTR&D/DAC/OAT


************
#include <iostream>
#include <fstream>

int main()
{
  std::ifstream ifs;

  ifs.open("FOO");
  std::cout << (bool)ifs << std::endl;
  std::string str;
  while(ifs) {
    getline(ifs, str);
    std::cout << str << std::endl;
  }
  ifs.close();
  ifs.open("FOO");
  std::cout << (bool)ifs << std::endl;
  while(ifs) {
    getline(ifs, str);
    std::cout << str << std::endl;
  }
  ifs.close();
}

***********
$ cat FOO
blah
$

************
$ ./a.out
1
blah

0
*************

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