I finished resize after spending days on it and took a week break, today I read what recover is and after reading it I am having that feeling as to what to do where to start from? Have spend like ours reading the specs and thinking about it still could not understand. Having that feel that i havent learnt any thing and that I dont know C and etc and its scaring me, I really wanted to complete this course and get a certificate but i am getting the feeling this is where I might quit.... Plz help, any sort of help would be appreciated. Anyone else found recover this much tough?
#include <stdio.h>
include
include
int main(int argc, char* argv[]) { // open card file FILE* inptr = fopen("card.raw", "r");
// check for errors
if (inptr == NULL)
{
printf ("could not open card. \n");
return 1;
}
// declaring a block of 8 bits of Type BYTE and having 512 blocks
typedef uint8_t BYTE;
BYTE block[512];
int counter = 0;
while (true)
{
// checking for if end of data on card has reached.
if(feof(inptr))
{
break;
}
fread(&block, 512, 1, inptr);
// checking for headers of JPEGs
if (block[0] == 0xff && block[1] == 0xd8 && block[2] == 0xff && (block[3] == 0xe0 || block[3] == 0xe1))
{
char name[7];
sprintf(name, "00%i.jpg", counter);
FILE* picture = fopen(name, "w");
fwrite(&block , 512, 1, picture);
// going on to next block
fread(&block, 512, 1, inptr);
//loop for keep on reading blocks by blocks after the header
while (block[0] != 0xff && block[1] != 0xd8 && block[2] != 0xff && (block[3] != 0xe0 || block[3] != 0xe1))
{
fwrite(&block, 512, 1, picture);
fread(&block, 512, 1, inptr);
}
fclose(picture);
counter++;
}
}
}