I'm stuck on recover. My code runs and creates the files, but does it does not appear successful at recovering the pictures.
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if (argc != 2)
{
fprintf(stderr, "Please enter no more or no less than one filename.\n");
return 1;
}
char *infile = argv[1];
FILE *inptr = fopen(infile, "r");
if (inptr == NULL)
{
fprintf(stderr, "Could not open %s.\n", infile);
return 2;
}
int i = 0;
unsigned char buffer[512];
while (fread(buffer, 512, 1, inptr)!=0)
{
if (buffer[0]==0xff && buffer[1]==0xd8 && buffer[2]==0xff && (buffer[3] & 0xf0)==0xe0)
{
char file_name[0];
sprintf(file_name, "%03i.jpg", i);
i++;
FILE *outptr = fopen(file_name, "w");
fwrite(buffer, sizeof(buffer), 1, outptr);
fclose(outptr);
}
}
fclose(inptr);
}
if (buffer[0]==...
line...