I am currently working on recover(pset4).I have recovered all 50 images but partially.Don't know what is wrong with the code...Any help is appreciated.Here is the link to the code https://gist.github.com/belogical/cc5c888d850aaac08a54c21536e935c0
Ask de Morgan (Disclaimer: I've studied physics, boolean logic was part of the maths curriculum)
The opposite of
I have some bad feeling about
ch=fgetc(inptr); (doesn't this get you out-of-sync?), and also the
fseek looks suspicious (as if it wanted to lead you into an infinite loop without that
fgetc). Maybe something like
if (no == 512) fseek...
buffer for the input file name is interesting.
I did it slightly differently, having only one
fread, in the
while condition. Then, within the loop, on finding a JPEG header, I'd start a new output file, and independently (no else), if there is an open output file, I'd write that block to disk (so also only one
fwrite). Personal preference maybe.