Operating System - HP-UX
1820707 Members
2705 Online
109627 Solutions
New Discussion юеВ

Reading a binary file in C++ and determining EOF

 
SOLVED
Go to solution
Kimberly Lewis
New Member

Reading a binary file in C++ and determining EOF

When using C++ to read a graphic (binary) file that may contain characters equivilent to EOF marker, how can I be certain that I have reached the end of file?
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor

Re: Reading a binary file in C++ and determining EOF

Hi Kimberly:

I assume that this is a UNIX question. There is no EOF character, one simply reads until no data is left.
If it ain't broke, I can fix that.
Chris De Angelis
Frequent Advisor

Re: Reading a binary file in C++ and determining EOF

And to know you've read to the end of the file, perhaps you need to do a check of your current position relative to the size of the file. Or just keep reading until your read returns an error.

Are you using a good spec of the particular graphic file format you are trying to read in?
harry d brown jr
Honored Contributor
Solution

Re: Reading a binary file in C++ and determining EOF

Like Clay said, there is no EOF characters, only a condition where your read returns an EOF.


Does this make sense?


live free or die
harry
Live Free or Die