I could get this code from a forum and modify it to be an easy code for reading. This code read any binary file then print the binary output as a hexdecimal raw.
#include <stdio.h>
int main (int argc, char **argv) {
unsigned char buf[1] = {0};
size_t bytes = 0, i, readsz = sizeof buf;
FILE *fp = fopen("system.bin", "rb");
while ((bytes = fread (buf, sizeof *buf, readsz, fp)) == readsz) {
for (i = 0; i < readsz; i++)
printf ("%02x ", buf[i]);
}
return 0;
}
An example of the output:
F7 F7 3B AF F7 2B BF DF 5C CE 9C
I have two questions:
As per my knowledge all binary files on your computer are saved as a binary format like this
10100100101
so why the output wasn't like10100100101
.I do not want to convert the hexadecimal to binary format, I just want to read the binary file as a binary format not hexadecimal format.