forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[Fixed] Displaying binary data in hex?

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
flaxum



Joined: 13 Oct 2005
Posts: 4

PostPosted: Mon Nov 14, 2005 3:31 am    Post subject: [Fixed] Displaying binary data in hex? Reply with quote

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
View user's profile Send private message
weltall



Joined: 20 Feb 2004
Posts: 310

PostPosted: Mon Nov 14, 2005 6:22 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
sherpya



Joined: 03 Oct 2005
Posts: 61

PostPosted: Mon Nov 14, 2005 7:48 am    Post subject: Reply with quote

for each char byte
check isprint(c)
if true print it else print a dot
Back to top
View user's profile Send private message
cheriff
Regular


Joined: 23 Jun 2004
Posts: 262
Location: Sydney.au

PostPosted: Mon Nov 14, 2005 9:32 am    Post subject: Reply with quote

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
View user's profile Send private message
flaxum



Joined: 13 Oct 2005
Posts: 4

PostPosted: Mon Nov 14, 2005 10:39 am    Post subject: Reply with quote

Works great, thanks all!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group