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

Number digits to ASCII

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



Joined: 07 Feb 2008
Posts: 167

View user's profile Send private message

Number digits to ASCII
PostPosted: Fri Oct 29, 2010 2:49 pm     Reply with quote

I know there's an elegant method to do this, but I'm in brain freeze.

I need to convert an int16 to a five element array containing the ASCII values for each of the five numerical digits. In other words:

53375= {35,33,33,37,35}, etc.

Anyone?

Thanks Embarassed
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Oct 29, 2010 3:01 pm     Reply with quote

The quick way is to use sprintf to convert the int16 to ASCII digits and
write to an array. It does it all for you.

Make sure you declare an that's big enough to hold all the digits,
and the string terminator byte at the end. Make the array big
enough to cover anything you might give it.
Jerry R



Joined: 25 Apr 2007
Posts: 23

View user's profile Send private message

PostPosted: Fri Oct 29, 2010 5:05 pm     Reply with quote

Thanks PCM, I'll give it a try. I appreciate your reply and getting my brain back in gear!

Regards
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