Wouldn't it be useful to actually openSo let's look at the first file????code that handles the non-signature blocks.
else
// if first jpg{
// if (countfile ==is 0)open
{
if (ftell(img) >= 0)
count++;
{
fwrite(buffer, 512, 1, img);
}
}
It's supposed to discard the initial garbage blocks and write out blocks after the first signature is found. But what's really happening?
First, the code opens the first output file for write. Then it reads the first block of data (which is garbage and should be thrown away.)
The test is if (ftell(img) >= 0)
. But if the file is just opened and nothing has been written to it, wouldn't ftell(img) return 0? What happens then?????
BTW, did you actually look at the first 4 bytes of 001.jpg instead of just trying to open the image??? The answers are always in the raw data.
Happy coding! :-)
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)