0

I am working on recover.c/pset4 and my code just exists & compiles & handles lck of forensic image , passes none of other checks. Check50 output is :

:) recover.c exists :) recover.c compiles :) handles lack of forensic image :( recovers 000.jpg correctly :( recovers middle files correctly \ expected 001.jpg to exist :( recovers last file correctly \ expected 015.jpg to exist https://sandbox.cs50.net/checks/89d186cc7f904244a304572578f5fe5a

Any suggestions will be appreciated!

0

Pattern "%03i.jpg" requires eight, not seven, char in filename1 (seven characters plus null terminator).

Don't open an output file before you've met the first JPG signature.

Inside the loop, you fopen(filename1, "w"); without assigning the result to a variable (probably img1).

The three counters are not really clear. A single counter should be enough, starting at 0 and incremented after opening a new output file.

Don't forget to close open files after your loop.

The code

while(!feof(inptr))
{
    if(fread(&buffer,1,512,inptr) == 512)
    {
        ...
    }
}

is same as

while(fread(&buffer,1,512,inptr) == 512)
{
    ...
}

(feof returns 0 as long as the last read operation worked)

1
  • Cheers! I fixed all that up. I was doing blunders like those u spotted above but now everything seems to work as I really understand pointers well.Thanks for ur help!
    – sk.76
    Jun 29 '17 at 11:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .