You need first open bmp file in a binary mode:
FILE* f = fopen("1.bmp", "rb");
Then read file byte by byte and display its hex values:
while (!feof(f))
printf("%02X ", fgetc(f));
Close file after using:
fclose(f);
Whole source:
#include <stdio.h>
int main()
{
FILE* f = fopen("1.bmp", "rb");
if (f == 0)
return 1;
while (!feof(f))
printf("%02X ", fgetc(f));
fclose(f);
return 0;
}
Comments
Leave a comment