|
-
September 13th, 2004, 09:57 AM
#1
Is fucntion ifstream::eof() reasonable?
Please take a look at the code listed below:
const char *cszFilePath = "TestFile";
ofstream ofs;
ofs.open(cszFilePath, ios_base: ut | ios_base::binary);
int iSize = 3;
ofs.write((char *)&iSize, sizeof(int));
ofs.close();
ifstream ifs;
ifs.open(cszFilePath, ios_base::in | ios_base::binary);
int iTemp;
ifs.read((char *)&iTemp, sizeof(int));
bool bEOF = ifs.eof();
Since there is only one integer in the file "TestFile", after reading a integer from the input file stream, bEOF should be true here, but actually its value is FALSE!
Who can explain this to me? Thank you very much for your help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|