0

I get the output of all 50 images which can be viewed but it fails all CS50 checks.

:) recover.c exists :) recover.c compiles :) handles lack of forensic image :( recovers 000.jpg correctly :( recovers middle files correctly :( recovers last file correctly \ expected 015.jpg to exist

This is my code https://pastebin.com/D9UMgSCW

Can I know where am I wrong?

Thank you.

  • sandbox.cs50.net/checks/f5fd37b8e3254e748948134ec8eecaf1 This is my check50 output – Abhinav Jain May 21 '17 at 11:50
  • Advice only, not an answer: I have never seen a "4 byte" solution work for this pset. Usually it fails when there is a 4 byte sequence in the middle of a jpg that matches the sig. (Spoiler alert: check50 uses such a file). Think about how to approach this the "greedy" way. For each 512 byte block there are 3 options: 1) skip it 2) start a new jpg 3) add to existing jpg. No muss, no fuss, no fseek. And FWIW, memcmp does not return a bool. – DinoCoderSaurus May 22 '17 at 13:37
  • Only the first 4 bytes are checked for the signature in every 512 byte block in the code(apart from when it is looking for the first JPG), it doesn't search a middle of the JPG for one, also memcmp returns a 0 on match and a number other than 0 when the memory blocks are not equal so that works. – Abhinav Jain May 23 '17 at 18:08

You must log in to answer this question.

Browse other questions tagged .