So I have a very simple program that reads the 3 first bytes of a file:
int main(void) { FILE *fd = NULL; int i; unsigned char test = 0; fd = fopen(
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.
Please look at this question Reading bytes from bmp file.
Looks like problem is in the mode of opening it.