I keep ending up with this last error on Check50 - any tips?
int main(int argc, char *argv[])
{
// Check for invalid usage
if (argc != 2)
{
printf("Usage: Recover [file name ...]\n");
return 1;
}
// opens the file i.e. memory card
FILE *file = fopen(argv[1], "r");
// image number for each file created
int i=0;
FILE* outptr = NULL;
uint8_t block[512];
// If we are not at the end of the file, do the following
while(!feof(file))
{
// read 512 bytes worth i.e. the first block
fread( block, 512, 1, file);
// if the first 4 bytes of the block indicate that it is a new JPEG then open a file if a location for the output file doesn't exist
if ( block[0] == 0xff && block[1] == 0xd8 && block[2] == 0xff && ((block[3] & 0xf0) == 0xe0) )
{
if (outptr != NULL)
{
fclose(outptr);
}
char filename[8];
sprintf(filename, "%03i.jpg", i);
outptr = fopen(filename, "w");
i++;
fwrite(block, sizeof(block), 1, outptr);
}
else if( i > 0)
{
fwrite(block, sizeof(block), 1, outptr);
}
}
fwrite(block, sizeof(block), 1, outptr);
fclose(outptr);
fclose(file);
}
'''