My code:
//create space save info from card
unsigned char buffer[512];
int jpgCount = 0;
char title[7];
do
{
if (buffer[0] == 0xff && buffer[1] == 0xd8 && buffer[2] == 0xff)
{
sprintf(title, "00%i.jpg", jpgCount);
FILE* img = fopen(title,"a");
printf("This is the start of a jpg file! This is JPG number: %i \n",jpgCount);
fclose(img);
jpgCount++;
}
}
while (fread(buffer, 512, 1, file) == 1);
fclose(file);
return 0;
}
The outcome is not what I expected though.The program correctly identifies the jpgs 50 times, printing out"This is the start of a jpg file! This is JPG number: 0 " 50 times! Why doesn't the variable add up? Also, only one file is opened. What am I missing that's messing this while loop up?
Appreciate your help!