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

Convert integer to string

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







Convert integer to string
PostPosted: Thu Oct 14, 2004 12:14 pm     Reply with quote

Hi all,


With the PIC18F1320 I communicate with a Diplay(EA Dip204-4) over the serial SPI Interface. The data which I send are in an integer variable (for example: 50). The Problem is I can only send an string variable (for example: char value[]="50") to the display.
My Question: It`s possible to convert an integer to a string?

thanks for the help

Sorry for my bad English ;)
dave



Joined: 21 Dec 2003
Posts: 7
Location: Sheffield, South Yorks, UK

View user's profile Send private message

PostPosted: Thu Oct 14, 2004 12:33 pm     Reply with quote

Use the sprintf() function as described in the CCSC manual, as is pasted below. Very Happy
Code:
SPRINTF()
 

Syntax:
 sprintf(string, cstring, values...);

 
 
Parameters:
 string is an array of characters.

cstring is a constant string or an array of characters null terminated.  Values are a list of variables separated by commas.

 
 
Returns:
 Nothing

 
 
Function:
 This function operates like printf except that the output is placed into the specified string.  The output string will be terminated with a null.  No checking is done to ensure the string is large enough for the data.  See printf() for details on formatting.

 
 
Availability:
 All devices.

 
 
Requires
 Nothing

 
 
Examples:
 char mystring[20];

long mylong;

 

mylong=1234;

sprintf(mystring,"<%lu>",mylong);

// mystring now has:

//      < 1 2 3 4 > \0

 
 
Example Files:
 None

 
 


regards Dave
Jack_B
Guest







PostPosted: Thu Oct 14, 2004 1:15 pm     Reply with quote

thanks for the detailed answer Very Happy
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