this is my code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
// Check usage
if (argc != 2)
{
return 1;
}
// Open file
FILE* file = fopen(argv[1], "r");
if (!file)
{
return 1;
}
// Read first three bytes
// unsigned char data[999999];
// int size = fread(data, 1, 999999, file);
int num = -1;
while(1 == 1){
unsigned char data[512];
size_t size = fread(data, 1, 512, file);
if(size < 512 / 4) break;
if (data[0] == 0xff && data[1] == 0xd8 && data[2] == 0xff)
{
num++;
}
if (num > -1)
{
char filename[7];
sprintf(filename, "%03i.jpg", num);
FILE* jpeg = fopen(filename, "w");
fwrite(&data, 1, 512, jpeg);
}
}
// Close file
return 0;
}
and this is what check50 says:
:) recover.c exists.
:) recover.c compiles.
:) handles lack of forensic image
:( recovers 000.jpg correctly
recovered image does not match
:( recovers middle images correctly
recovered image does not match
:( recovers 049.jpg correctly
recovered image does not match
My code does work (if the images are supposed to be completely transparent) but check 50 says something is off :(. I really need some help and i don't want to use the code from other question(s) like this one that did slightly better than mine in check50, so please don't mark this as duplicate. Thanks for the help!