Hello,
I'm now developing a home project, but before I start, I need to know how can I print the content of a file(*.bin as example) in hexadecimal.
I like to learn, then a good tutorial is very nice too ;)
Best Regards,
Nathan Paulino Campos
Printable View
Hello,
I'm now developing a home project, but before I start, I need to know how can I print the content of a file(*.bin as example) in hexadecimal.
I like to learn, then a good tutorial is very nice too ;)
Best Regards,
Nathan Paulino Campos
x for lowercase hex letters, X for uppercase letters
Google is your friend for all kinds of C and C++ online tutorials.
I'm not sure but I suggest reading every character and then using the printf function with %hhx to print every byte of the file.
for example:
char c
while file has next
c = next character
printf("%hhx", c)
That's what I would try first.
You'd probably want to fread() BUFSIZ bytes at a time ("The value of BUFSIZ is chosen on each system so as to make stream I/O efficient."). Then use printf() as above -- although that might be a little slow depending on how many characters you have.
If Linux:
od -t x1 filename.bin