Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Binary EOF 1

Status
Not open for further replies.

JGSH

Programmer
Feb 23, 2003
6
US
hi,
I'm trying to read a binary file 1 byte at a time using the get() function. I am doing this in a while loop, and supposed the file is ABC. The program runs through the loop four times instead of only 3. How can I fix this so that it ends after it reads the C ? I'm currently using,

while( !myFile.eof() )
myFile.get(ch);

thanx
 
Try to use this formulation instead:

Code:
while( ( myFile.get( ch ) ) && !myFile.eof() )
{
   .....
   ...
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top