when i run the cod i can see the files but when i open it i can't see any pictures and also not all of the 50 files showed only 21.
#include <stdio.h>
#include <stdint.h>
int main(void)
{
// TODO
unsigned char original1[512] = {0xff, 0xd8, 0xff, 0xe0};
unsigned char original2[512] = {0xff, 0xd8, 0xff, 0xe1};
unsigned char buffer[512];
FILE* outfile;
FILE* memory = fopen("card.raw", "r");
if (memory == NULL)
{
return 1;
}
int count = 0;
int match = 0;
int check = 0;
char name[8];
while(!feof(memory))
{
fread(&buffer, 512, 1, memory);
for(int i = 0; i < 4; i++)
{
if(original1[i] == buffer[i] || original2[i] == buffer[i])
{
match++;
}
}
if(match == 4)
{
if(check == 1)
{
fclose(outfile);
}
sprintf(name, "%.3d.jpeg", count);
outfile = fopen(name, "w");
if(outfile == NULL)
{
return 2;
}
count++;
fwrite(&buffer, 512, 1, outfile);
check = 1;
}
else if(check == 1)
{
fwrite(&buffer, 512, 1, outfile);
}
else
{
check = 0;
}
}
fclose(memory);
fclose(outfile);
return 0;
}