|
-
Jun 29th, 2002, 05:00 AM
#1
Thread Starter
Lively Member
problem with fstream's eof
Hi everyone.
I am using code like this:
while(!ifs.eof())
cout << hex << ifs.get() << '\n';
The file that I am using has exactly 283,858 bytes (i.e. it is fairly large); however, the thing thinks the last character is character #21,018, because that's when ifs.eof() returns true. Can anyone help me out here? Can anyone tell me to make it _know_ that the last character is at character #283,857? Thanks.
- Justin Patrick Butler
Comme je trouve. "As I find."
- Butler family quote
Beneficia sumptos procul superant. "The benefits far exceed the costs."
- Myself
-
Jun 29th, 2002, 05:15 AM
#2
Monday Morning Lunatic
What type of file is it - is it binary? If it is you need to make sure you're opening the stream as ios::binary.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
-- Linus Torvalds
-
Jun 29th, 2002, 05:30 AM
#3
Thread Starter
Lively Member
Yes that was the problem!
Thank you!
- Justin Patrick Butler
Comme je trouve. "As I find."
- Butler family quote
Beneficia sumptos procul superant. "The benefits far exceed the costs."
- Myself
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
|