Answer to Question #123090 in C for warda

Question #123090
Write a program in C programming language, that will open a bitmap image file in read mode, reads its contents, and display it on the screen
1
Expert's answer
2020-06-23T06:16:51-0400

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;

}



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS