I am trying to read the bytes of an image file in C, specifically a PNG, in the following manner:
#include <stdio.h>
int main(){
FILE* fd = fopen("logo.png", "r");
char c = fgetc(fd);
while(c != EOF){
printf("%c", c);
c = fgetc(fd);
}
return 0;
}
When I run the program, I get he following:
<89>PNG^M
^Z
^@^@^@^MIHDR^@^@^@
Why does it only go to a certain byte and then completely exit reading the file?How would I fix this issue?