| View previous topic :: View next topic |
| Author |
Message |
flaxum
Joined: 13 Oct 2005 Posts: 4
|
Posted: Mon Nov 14, 2005 3:31 am Post subject: [Fixed] Displaying binary data in hex? |
|
|
I'm working on an IR program (based off of Vanya Sergeev's), and I was wondering if there's any way to display the data in hex?
Currently, it only displays odd symbols, which do not help very much.
Thanks
Last edited by flaxum on Tue Nov 15, 2005 9:28 am; edited 1 time in total |
|
| Back to top |
|
 |
weltall
Joined: 20 Feb 2004 Posts: 310
|
Posted: Mon Nov 14, 2005 6:22 am Post subject: |
|
|
if you use printf you can use %x to display in hex format a variable like this:
printf("variable x: %x\n", variable_x); |
|
| Back to top |
|
 |
sherpya

Joined: 03 Oct 2005 Posts: 61
|
Posted: Mon Nov 14, 2005 7:48 am Post subject: |
|
|
for each char byte
check isprint(c)
if true print it else print a dot |
|
| Back to top |
|
 |
cheriff Regular
Joined: 23 Jun 2004 Posts: 262 Location: Sydney.au
|
Posted: Mon Nov 14, 2005 9:32 am Post subject: |
|
|
Following on from weltall's reply, I usually use | Code: | | printf("variable x: %08x\n", variable_x); | To zero pad the number out to 8chars, or 32 bits. _________________ Damn, I need a decent signature! |
|
| Back to top |
|
 |
flaxum
Joined: 13 Oct 2005 Posts: 4
|
Posted: Mon Nov 14, 2005 10:39 am Post subject: |
|
|
| Works great, thanks all! |
|
| Back to top |
|
 |
|