/**
* recover.c
*
* Computer Science 50
* Problem Set 4
*
* Recovers JPEGs from a forensic image.
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
int main(void)
{
FILE* file = fopen("card.raw", "r");
if (file == NULL)
{
return 1;
}
for (int i = 0; i < 51; i++)
{
sprintf(title, "00%d.jpg", i);
FILE* img = fopen(title, "a");
int* buffer = malloc(sizeof(uint8_t) * 512);
if(fread(&buffer, 512, 1, file) == 0xffd8ffe)
{
fwrite(&buffer, 512, 1, file);
fclose(file);
free(buffer);
}
}
}
I'm getting:
recover.c:23:17: error: use of undeclared identifier 'title'; did you mean 'file'?
sprintf(title, "00%d.jpg", i);
^~~~~
file
recover.c:15:11: note: 'file' declared here
FILE* file = fopen("card.raw", "r");
^
recover.c:24:27: error: use of undeclared identifier 'title'; did you mean 'file'?
FILE* img = fopen(title, "a");
^~~~~
file
recover.c:15:11: note: 'file' declared here
FILE* file = fopen("card.raw", "r");
^
2 errors generated.