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 support@ccsinfo.com

int to char

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



Joined: 03 Apr 2006
Posts: 1

View user's profile Send private message

int to char
PostPosted: Mon Apr 10, 2006 12:30 am     Reply with quote

Hello,

i am trying to send an integer value over the RS232 using the function putc(), which have a parameter char,

does anybody have an idea?

thanx
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Apr 10, 2006 1:00 am     Reply with quote

If you want to send a binary number which is larger than a byte,
such as an int16 for int32 value, then can use the CCS make8()
function to extract the individual bytes and send them with putc().
Look in the manual for information on using make8().


If you want to see the number that you're sending, in a terminal
window on your PC (such as Hyperterminal), then you need to
send the value as ASCII digits. You can use printf() for that.
Again, see the CCS manual for more information on printf().
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

Bits is bits
PostPosted: Mon Apr 10, 2006 6:46 am     Reply with quote

A standard CCS int is 8 bits so it fits nicely in a char. You can putc() an 8 bit int with no problems. But formally you could cast it to a char first. Casting would improve readability and there would be no code overhead.
_________________
The search for better is endless. Instead simply find very good and get the job done.
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