Hello,
I am a newbie to programming so please bare with me
I am trying to extract specific bytes from a hex file... Actually I am trying to create a program that extracts a .jpg from a hex file. So far, I have code that can extract the bytes and out put them to a .jpg until I reach EOF. But, I specifically need to have the program stop once it comes across bytes FF D9 in the hex file without using EOF. It is very important that the program stops once it reaches bytes FF d9 within the hex file for specific data to be extracted. I don't know how I would do this??? I have spend hours on trying to figure this out but I just can't seem to find a solution. This is what I have so far, the code written below is a function to extract a jpg from a hex file:
Code:
//extracts the bytes from the inputHexFile and ouputs the bytes to a jpg
void JpegFile ()
{
(void)fseek( inputHexFile, 33, SEEK_SET ); //skip over the first 33 bytes
outputJpegFile = fopen("C:/Documents and Settings/student/Desktop /Image.jpg", "wb"); //open Image.jpg
//read the bytes from inputHexFile until the End Of File then output the bytes to outputJpegFile
while ((c = fgetc(inputHexFile)) != EOF ) //Needs to be modified to only get bytes until it reaches ff d9
{
fputc(c, outputJpegFile); // outputs bytes to jpeg file
} //end while
fclose(outputJpegFile); // close file
}// end JpegFile()
Thanks in advance for any help