0

I would like some help with recover, after few days of struggle I managed tp finish pset4 recovering all 50 images from file but when i run the cs50 check test it gives me this error

$ check50 2015.fall.pset4.recover recover.c
:) recover.c exists
:) recover.c compiles
:( recovers 000.jpg correctly
   \ expected an exit code of 0, not standard error of "/opt/sandbox50/bin/run.sh: line 31: 235..."
:( recovers middle files correctly
   \ expected an exit code of 0, not standard error of "/opt/sandbox50/bin/run.sh: line 31: 235..."
:( recovers last file correctly
   \ expected an exit code of 0, not standard error of "/opt/sandbox50/bin/run.sh: line 31: 236..."
https://sandbox.cs50.net/checks/4804c3b5146448b2bc4b48464c9bc88f

here you can find a link off my code

Thank you in advance!!!

Hello again, that really worked I added an if condition in the begining of code to create an title for the jpg file so i wont get SEGF error

 if(index > 0)
    {
        sprintf(title,"%03i.jpg", index - 1);  
    }
    else if (index == 0)
    {
        sprintf(title,"%03i.jpg", index);    
    }

and moved fclose(img) from if condition to the end of while so it can be closed each time.

That worked perfectly :). Thank you!!!!

2

Your code is opening an output file on the first and every pass through the loop. Unfortunately, before finding the first signature, it isn't setting the contents of title in preparation. Also, it isn't closing the file before opening the first actual output file.

It's interesting that the seg fault isn't showing up when executed in the IDE. I have no explanation for that, but I'm still looking.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

You must log in to answer this question.

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