You need to open the file in binary mode:
fd = fopen("test.bmp", "rb");
If you try to read a binary file like a bitmap in text mode, the bytes corresponding to carriage returns and linefeeds confuse things.
anon
2010-07-09 09:57:08