delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/07/17/20:54:22

Message-ID: <3973AAC0.FD795944@gmx.de>
Date: Tue, 18 Jul 2000 02:54:24 +0200
From: Hanno Stehling <hstehling AT gmx DOT de>
X-Mailer: Mozilla 4.6 [de]C-CCK-MCD QXW0321s (Win98; I)
X-Accept-Language: de,en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Problem with ifstream.eof()
Reply-To: djgpp AT delorie DOT com

ifstream.eof() returns FALSE, although the current position in the file
is EOF. After reading one more byte, ifstream.eof() returns TRUE, but,
of course, ifstream.good() returns FALSE.

example code:
Let's say "test.dat" is a file with a size of exactly 10 Bytes.

ifstream f1("test.dat", ios::in | ios::bin);
unsigned char buffer[10];
f1.read(buffer, 10);

Now, I think, f1.eof() should return TRUE, but it returns FALSE.

f1.read(buffer, 1);

Now, after reading one Byte too much, it returns TRUE.


Thanks for answering,
HST

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019