I am stuck with my recover code. The compiler yells at me because I am doing a incompatible pointer to integer conversion but I can't see where...
recover.c:28:18: error: passing 'BYTE [512]' to parameter of type 'char *' converts between pointers to integer types with different sign
[-Werror,-Wpointer-sign]
code
int main(int argc, char* argv[])
{
// open file to recover
FILE *card = fopen("card.raw", "r");
if (card == NULL)
{
printf("Could not open file. Retry!");
return 2;
}
// declare buf
typedef uint8_t BYTE;
BYTE buf[512];
// read card in chunks of 512byte (FAT32 blocks)
while (fgets(buf, sizeof(buf), card) != NULL)
{
fread(buf, 512, 1, card);
if (buf[0] == 0xff && buf[1] == 0xd8 && buf[2] == 0xff && (buf[3] == 0xe0 || buf[3] == 0xe1))
{
int jpgnumber = 1;
FILE *jpg = fopen(("%02d.jpg", jpgnumber), 'w');
fwrite(&buf, 512, 1, jpg);
fread(&buf, 512, 1, card);
// !another jpg header
while (buf[0] != 0xff && buf[1] != 0xd8 && buf[2] != 0xff && (buf[3] != 0xe0 || buf[3] != 0xe1))
{
fwrite(&buf, 512, 1, jpg);
fread(&buf, 512, 1, card);
}
fclose(jpg);
jpgnumber++;
}
}
fclose(card);
return 0;
}