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

Converting INT to CHAR

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



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

Converting INT to CHAR
PostPosted: Sat Feb 23, 2013 2:52 am     Reply with quote

Hi! Is there a standard function for conversion of int to char? My goal is to convert an integer value (for example 45 to string "45") and then to use this value for file creation. Can you tell me an easy way to do this?
Thanks!
Ttelmah



Joined: 11 Mar 2010
Posts: 19537

View user's profile Send private message

PostPosted: Sat Feb 23, 2013 3:31 am     Reply with quote

sprintf

Code:

  unsigned int8 ival=45;
  char str_buffer[5]; //remember the buffer must be large enough to
  //include the terminating '\0' which makes the data into a 'string'

  sprintf(str_buffer,"%u",ival);


Read the manual (or a generic 'C' book), for the formatting values.

Best Wishes
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