[Fixed] Displaying binary data in hex?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
flaxum
Posts: 4
Joined: Thu Oct 13, 2005 1:33 pm

[Fixed] Displaying binary data in hex?

Post by flaxum »

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.
weltall
Posts: 310
Joined: Fri Feb 20, 2004 1:56 am
Contact:

Post by weltall »

if you use printf you can use %x to display in hex format a variable like this:
printf("variable x: %x\n", variable_x);
User avatar
sherpya
Posts: 61
Joined: Mon Oct 03, 2005 5:49 pm

Post by sherpya »

for each char byte
check isprint(c)
if true print it else print a dot
cheriff
Regular
Posts: 258
Joined: Wed Jun 23, 2004 5:35 pm
Location: Sydney.au

Post by cheriff »

Following on from weltall's reply, I usually use

Code: Select all

printf("variable x: %08x\n", variable_x);
To zero pad the number out to 8chars, or 32 bits.
Damn, I need a decent signature!
flaxum
Posts: 4
Joined: Thu Oct 13, 2005 1:33 pm

Post by flaxum »

Works great, thanks all!
Post Reply