Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock 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
Mar 3, 2004
494
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



 
Replies continue below

Recommended for you

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