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
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
Follow Me At Twitter
Eee PC 904HD White | Windows XP Home Edition and Linux Ubuntu Hardy Herron
Google Talk: [email protected]
ICQ: 424738586
AIM: nathanjava
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
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}