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 TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

end of file not recognized

Status
Not open for further replies.

2dye4

Military
Joined
Mar 3, 2004
Messages
494
Location
US
The following is my program

FILE *floppy;
FILE *destination;
floppy=fopen("a:\picture.jpg","rb");
destination=fopen("c:\pictures\save.jpg","rb");
do
{
hold=fgetc(floppy);
fputc(hold,destination);
}while(!feof(floppy);


The goal is copy a picture file from a floppy to
the hard drive. Worked fine until in encountered
a corrupt file on the floppy and then there was
no ending to this loop. feof never returned a non-zero
value. It wrote a 1.3 Gig file to my hard drive before
I canceled the program.
I know I can count bytes and stop at an absurd number
but there should be a more elegant way
This was compiled to a win32 console app with borland 5.5
and was running on Winxp home
any ideas
Thanks



 
You have header information in image files to help in such matters, so use it. No need to continue reading bytes. If the header info looks corrupted, there's no need to continue reading.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top