Wednesday, March 12, 2008

0x1A

I was using this Dev C++ version 4 to compile to code written to convert the jpeg to exif format. and after trying for 2 hours to debug my code, I came to know the actual bug.

Actually, whenever it encounters 0x1A in the source file, it reads it as 0xFF. I tried fscanf, fgetc, fread, but none of them seem to work with this. When I am reading using fgetc and printing on the stdout, it prints 0xFF, when it should actually print ox1A, and after that the program hangs. I think this is a bug in the compiler :)

yeye, no bug in my code :)

2 comments:

Kartik Mohta said...

Opening the file in binary mode (in fopen) doesn't cause this problem

hemant said...

yes, you are right. I was idiot to consider that as a compiler thing. It was a jpeg image, and opening in binary mode should allow to read all the hex data as it is on the disk.