Re: ifstream limitations?
- From: "Alex Blekhman" <tkfx.N05P4M@xxxxxxxxx>
- Date: Fri, 16 Sep 2005 00:18:20 +0259
Doug Harrison [MVP] wrote:
> [...]
> The while loop was:
>
>> while(in.good())
>> {
>
> [...]
>
> Both these approaches ignore the fact that EOF is
> discovered only when a read is attempted. The while loop
> above will discover EOF when it calls getline and may
> attempt to output a spurious empty string.
Agreed. It was written only as demonstration how to read
something from input file stream. I should have wrote it
with std::copy instead:
ifstream in("C:\\TEMP\\test.txt");
if(in.is_open())
{
copy(istream_iterator<string>(in),
istream_iterator<string>(),
ostream_iterator<string>(cout, "\n"));
in.close();
}
.
- References:
- Re: ifstream limitations?
- From: Doug Harrison [MVP]
- Re: ifstream limitations?
- Prev by Date: Re: How to write to environment variables?
- Next by Date: Re: throw()
- Previous by thread: Re: ifstream limitations?
- Next by thread: I am almost there!
- Index(es):
Relevant Pages
|