CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Hexadecimal to character Conversion

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Kookoo
Guest







Hexadecimal to character Conversion
PostPosted: Tue Jan 24, 2006 3:18 am     Reply with quote

Hello,

is there any function to convert a hexadecimal number to a character ?
Or to convert an ASCII number to a character ?

Many Thanks.
treitmey



Joined: 23 Jan 2004
Posts: 1094
Location: Appleton,WI USA

View user's profile Send private message Visit poster's website

PostPosted: Tue Jan 24, 2006 8:59 am     Reply with quote

What do you mean by character?
What are you trying to do. Be specific.
Kasper



Joined: 14 Jan 2004
Posts: 88
Location: Aurora, Ontario, Canada

View user's profile Send private message Visit poster's website

PostPosted: Tue Jan 24, 2006 9:46 am     Reply with quote

something more than what the printf function does?
KamPutty
Guest







Re: Hexadecimal to character Conversion
PostPosted: Tue Jan 24, 2006 10:24 am     Reply with quote

Kookoo wrote:
Hello,

is there any function to convert a hexadecimal number to a character ?
Or to convert an ASCII number to a character ?

Many Thanks.


Hi there,

If you mean that you have a value of lets say "0xFF" and you want to print it in hex and not decimal, you do have some options...

use the "%x|X" in printf (can apply to sprintf) etc.

~or~

create an array with the 16 values 0,1,2,3,4...f
then use the high and low nibbles to obtain that value in ascii

char_array[(value&0xf0)>>4] // high character
char_array[(value%0x0f)] // low character

make sense?

~Kam (^8*
KamPutty
Guest







Re: Hexadecimal to character Conversion
PostPosted: Tue Jan 24, 2006 10:26 am     Reply with quote

Kookoo wrote:
Hello,

is there any function to convert a hexadecimal number to a character ?
Or to convert an ASCII number to a character ?

Many Thanks.


Hi there,

If you mean that you have a value of lets say "0xFF" and you want to print it in hex and not decimal, you do have some options...

use the "%x|X" in printf (can apply to sprintf) etc.

~or~

create an array with the 16 values 0,1,2,3,4...f
then use the high and low nibbles to obtain that value in ascii

char_array[(value&0xf0)>>4] // high character
char_array[(value%0x0f)] // low character

make sense?

~Kam (^8*
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 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