×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

end of file not recognized

end of file not recognized

end of file not recognized

(OP)
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



RE: end of file not recognized

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources