Hey guys so I've hit a bit of a wall with Recover, when I run my program I get segmentation fault but I also don't know how to end off one jpeg when another header pops up? In essence, I'm not sure what I could use to close the jpeg and restart the process when another header is found.
My code:
//declare crucial variables
BYTE buffer[512];
int img_counter = -1;
char *flname = "0.jpg";
FILE *img = NULL;
//while loop to go through the card
while (fread(&buffer, 512, 1, card_file))
{
//if first 4 bytes of block = jpeg header, begin writing process. Otherwise keep writing to current jpeg
if (buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] == 0xff && (buffer[3] & 0xf0) == 0xe0)
{
img_counter++;
sprintf(flname, "%03i.jpg", img_counter);
img = fopen(flname, "w");
fwrite(&buffer, 512, 1, img);
}
else
{
//not sure what to put here to write the block with no headers in them to the jpg
}
}
//close the card after use (end the program)
fclose(img);
fclose(card_file);
return 0;
Thanks in advance for the help!
Kind Regards
PrimeBeat