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]

Re: Problem with ifstream


Benoit Sibaud wrote:
> 
> 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();

// I hope it'll help:-)
ifs.clear();

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

 -- Levente
 "The only thing worse than not knowing the truth is
  ruining the bliss of ignorance."

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