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

string help

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



Joined: 06 Mar 2008
Posts: 35
Location: pakistan

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

string help
PostPosted: Wed Apr 16, 2008 5:23 am     Reply with quote

how to copy
"1.0" in a string
if i do
Code:

char text[4];
strcpy(text,""1.0"");


the colors are not ok in CCS
_________________
sohail khan
Matro
Guest







PostPosted: Wed Apr 16, 2008 6:11 am     Reply with quote

Code:

strcpy(text,"\"1.0\"");


Matro
Matro
Guest







PostPosted: Wed Apr 16, 2008 6:13 am     Reply with quote

Code:

strcpy(text,"""1.0""");

Also works.

Matro
sohailkhanonline



Joined: 06 Mar 2008
Posts: 35
Location: pakistan

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Wed Apr 16, 2008 6:35 am     Reply with quote

Thanks Matro
_________________
sohail khan
sohailkhanonline



Joined: 06 Mar 2008
Posts: 35
Location: pakistan

View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger

PostPosted: Wed Apr 16, 2008 6:38 am     Reply with quote

by the way..
how can we declare a pointer string in CCS
will this code work..

char *ptr;
ptr="MATRO ROCKS";
printf("%s",ptr);

its not yet working for me....
_________________
sohail khan
Matro
Guest







PostPosted: Wed Apr 16, 2008 7:08 am     Reply with quote

The problem comes from this line :
Code:

ptr="MATRO ROCKS";

The problems is that the string is in ROM and so a pointer isn't possible

2 solutions :
- 1) copy the string from ROM to RAM manually
Code:

strcpy(ptr,"MATRO ROCKS");


- 2) ask the compiler to do so
Code:

#device PASS_STRINGS = IN_RAM
...
ptr="MATRO ROCKS";


Matro
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